center.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  1. <template>
  2. <view class="pages">
  3. <view class="" :style="{height: navHeight+'px' }"></view>
  4. <view class="page-bg">
  5. <img class="img" :src="staticUrl+'/img/center-index-bg.png'" alt="">
  6. </view>
  7. <view class="base-info page-wrap u-flex u-row-between" v-if="vuex_member_info.name">
  8. <view class="left u-flex">
  9. <u-avatar :src="avatar||staticUrl+'/img/avatar.png'" size="110rpx"></u-avatar>
  10. <view class="info">
  11. <view class="name ellipsis-1">{{vuex_member_info.name}}</view>
  12. <view class="level u-flex">
  13. <u-icon :name="staticUrl+'/img/level-01.png'" color="#333333" size="30rpx"></u-icon>
  14. <text class="level-name">{{vuex_member_info.levelName}}</text>
  15. </view>
  16. </view>
  17. </view>
  18. <u-icon @click="$u.route('/center/memberinfo',{type:'redirectTo'})" name="setting-fill" color="#333333" size="38rpx"></u-icon>
  19. </view>
  20. <view class="base-info page-wrap u-flex u-row-between" @click="goLogin" v-else>
  21. <view class="left u-flex">
  22. <u-avatar :src="staticUrl+'/img/avatar.png'" size="110rpx"></u-avatar>
  23. <view class="info">
  24. <view class="name ellipsis-1">立即登录</view>
  25. </view>
  26. </view>
  27. <u-icon name="setting-fill" color="#333333" size="38rpx"></u-icon>
  28. </view>
  29. <view class="property page-wrap u-flex u-row-between">
  30. <view class="property-item" @click="checkauth('/center/paycode')">
  31. <view class="up">
  32. <u-icon :name="staticUrl+'/img/paycode.png'" color="#333333" size="42rpx"></u-icon>
  33. </view>
  34. <view class="down">会员码</view>
  35. </view>
  36. <view class="property-item" @click="checkauth('/center/mybalance')">
  37. <view class="up">{{memberInfo.balance||0}}</view>
  38. <view class="down">余额</view>
  39. </view>
  40. <view class="property-item" @click="checkauth('/credits/creditslist')">
  41. <view class="up">{{memberInfo.credit||0}}</view>
  42. <view class="down">积分</view>
  43. </view>
  44. <view class="property-item">
  45. <view class="up">{{memberInfo.couponNum||0}}</view>
  46. <view class="down">优惠券</view>
  47. </view>
  48. </view>
  49. <view class="order-state">
  50. <view class="title u-flex u-row-between">
  51. <view class="left">订单中心</view>
  52. <view class="right u-flex" @click="$u.route('/shopping/order')">
  53. 全部订单
  54. <u-icon name="arrow-right" color="#00A447" size="24rpx"></u-icon>
  55. </view>
  56. </view>
  57. <view class="u-flex u-row-between">
  58. <view class="state" @click="orderClick(item,index)" v-for="(item,index) in orderState" :key="index">
  59. <view class="up">
  60. <u-icon :name="item.ico" color="#333333" size="60rpx"></u-icon>
  61. <u-badge v-if="item.badge" type="error" max="99" :value="orderBadge[item.badge]" :absolute="true" :offset="[0,0]"></u-badge>
  62. </view>
  63. <view class="down">{{item.name}}</view>
  64. </view>
  65. </view>
  66. </view>
  67. <view class="tools page-wrap">
  68. <view class="title">常用工具</view>
  69. <view class="tools-wrap u-flex u-row-left">
  70. <view class="tool-item"
  71. v-for="(item,index) in tools"
  72. @click="toolsClick(item)"
  73. :key="index">
  74. <view class="" v-if="item.chat==1">
  75. <button class="button-item" type="default" open-type="contact">
  76. <u-icon :name="item.ico" color="#333333" size="60rpx"></u-icon>
  77. <view style="margin-top: 10rpx;">在线客服</view>
  78. </button>
  79. </view>
  80. <view class="" v-else>
  81. <view class="up">
  82. <u-icon :name="item.ico" color="#333333" size="60rpx"></u-icon>
  83. </view>
  84. <view class="down">{{item.name}}</view>
  85. </view>
  86. </view>
  87. </view>
  88. </view>
  89. <!-- <u-overlay :show="showPayCode" @click="showPayCode = false">
  90. <view class="pay-code-warp u-flex u-row-center">
  91. <view class="rect" @tap.stop>
  92. <u--image :showLoading="true" :src="payCodeImg" width="180px" height="180px"></u--image>
  93. </view>
  94. </view>
  95. </u-overlay> -->
  96. <tabbar :tabbarIndexProps="2" />
  97. </view>
  98. </template>
  99. <script>
  100. import { systemInfo } from "@/mixin.js";
  101. import tabbar from "../components/tabbar.vue"
  102. export default {
  103. components:{
  104. tabbar
  105. },
  106. mixins:[systemInfo],
  107. data() {
  108. return {
  109. staticUrl:this.$commonConfig.staticUrl,
  110. avatar:this.$commonConfig.staticUrl+'/img/avatar.png',
  111. showPayCode:false,
  112. payCodeImg:'https://cdn.uviewui.com/uview/album/1.jpg',
  113. memberInfo:{},
  114. orderState:[
  115. // {name:'全部订单',status:'',ico:this.$commonConfig.staticUrl+'/img/orderstateico-all.png'},
  116. {name:'待付款',status:'0',ico:this.$commonConfig.staticUrl+'/img/orderstateico-01.png',badge:'noPayNum'},
  117. {name:'待发货',status:'1',ico:this.$commonConfig.staticUrl+'/img/orderstateico-all.png',badge:'deliverNum'},
  118. {name:'待收货',status:'2',ico:this.$commonConfig.staticUrl+'/img/orderstateico-02.png',badge:'collectNum'},
  119. {name:'待评价',status:'3',ico:this.$commonConfig.staticUrl+'/img/orderstateico-03.png',badge:'commentNum'},
  120. {name:'退款/售后',status:'7',ico:this.$commonConfig.staticUrl+'/img/orderstateico-04.png',badge:'refundNum'},
  121. ],
  122. orderBadge:{
  123. noPayNum:'0',
  124. deliverNum:'0',
  125. collectNum:'0',
  126. commentNum:'0',
  127. refundNum:'0',
  128. },
  129. tools:[
  130. // {name:'充值中心',url:'/center/recharge',ico:this.$commonConfig.staticUrl+'/img/tool-chongzhi.png'},
  131. {name:'地址管理',url:'center/addrlist',ico:this.$commonConfig.staticUrl+'/img/tool-map.png',checkauth:true},
  132. {name:'客服电话',phone:'',ico:this.$commonConfig.staticUrl+'/img/tool-phone.png'},
  133. {name:'购物车',url:'shopping/cart',ico:this.$commonConfig.staticUrl+'/img/center-icon-cart.png',checkauth:true},
  134. {name:'在线客服',chat:'1',ico:this.$commonConfig.staticUrl+'/img/center-icon-chat.png'},
  135. ]
  136. }
  137. },
  138. onShow() {
  139. if(this.vuex_member_info.name){
  140. this.getMemberInfo();
  141. this.statisticsOrder();
  142. }
  143. },
  144. onLoad() {
  145. this.getSystemInfo();
  146. },
  147. methods: {
  148. getMemberInfo(){
  149. this.$u.api.memberInfo({id:this.vuex_member_info.id}).then(res=>{
  150. this.memberInfo = res.data;
  151. this.avatar = res.data.avatar;
  152. this.$u.vuex('vuex_member_info', res.data);
  153. // console.log('memberInfo',this.memberInfo);
  154. }).catch(err=>{
  155. console.log('memberInfo',err.data);
  156. })
  157. },
  158. toolsClick(item){
  159. let that = this;
  160. console.log('item',item);
  161. if ('phone' in item) {
  162. if(!that.memberInfo.customerMobile){
  163. uni.showToast({
  164. title:'电话号码为空',
  165. icon:"none"
  166. })
  167. return
  168. }
  169. uni.makePhoneCall({
  170. phoneNumber: that.memberInfo.customerMobile,
  171. success() {
  172. console.log('success');
  173. },
  174. fail() {
  175. console.log('fail');
  176. }
  177. });
  178. return
  179. }
  180. if ('chat' in item) {
  181. return
  182. }
  183. if(item.checkauth){
  184. this.checkauth(item.url)
  185. }else{
  186. uni.$u.route(item.url);
  187. }
  188. },
  189. orderClick(item,index){
  190. console.log('item',item);
  191. uni.$u.route('/shopping/order', {
  192. // current: index,
  193. status: item.status,
  194. type: 'redirectTo'
  195. });
  196. },
  197. statisticsOrder(){
  198. this.$u.api.statisticsOrder().then(res=>{
  199. let data = res.data || {};
  200. this.orderBadge = Object.assign(this.orderBadge,data)
  201. // console.log('statisticsOrder',res.data);
  202. // console.log('this.orderBadge',this.orderBadge);
  203. }).catch(err=>{
  204. console.log('memberInfo',err.data);
  205. })
  206. },
  207. goLogin(){
  208. uni.setStorage({
  209. key: 'backUrl',
  210. data:'center/center' ,
  211. success: function () {
  212. uni.$u.route('/pages/login/login')
  213. }
  214. });
  215. },
  216. checkauth(pageUrl){
  217. if(this.vuex_member_info.name){
  218. uni.$u.route(pageUrl)
  219. }else{
  220. uni.showModal({
  221. title: '提示',
  222. content: '你需要登录后,才可使用此功能!',
  223. success: res => {
  224. if (res.confirm) {
  225. uni.setStorage({
  226. key: 'backUrl',
  227. data:pageUrl ,
  228. success: function () {
  229. uni.$u.route('/pages/login/login')
  230. }
  231. });
  232. }
  233. }
  234. })
  235. }
  236. }
  237. }
  238. }
  239. </script>
  240. <style>
  241. page{
  242. background-color: #F5F5F5;
  243. padding-top: 0;
  244. }
  245. </style>
  246. <style lang="scss" scoped>
  247. .title{
  248. font-size: 32rpx;
  249. font-weight: 600;
  250. color: #333333;
  251. line-height: 45rpx;
  252. margin-bottom: 30rpx;
  253. }
  254. .base-info{
  255. margin-bottom: 10rpx;
  256. .info{
  257. margin-left: 30rpx;
  258. .name{
  259. font-size: 40rpx;
  260. font-weight: 600;
  261. color: #333333;
  262. line-height: 56rpx;
  263. margin-bottom: 10rpx;
  264. }
  265. .level{
  266. width: fit-content;
  267. background: linear-gradient(131deg, #FFF2DB 0%, #FFD9A5 100%);
  268. border-radius: 2px;
  269. font-size: 22rpx;
  270. font-weight: 400;
  271. color: #333333;
  272. line-height: 30rpx;
  273. padding: 6rpx 16rpx;
  274. .level-name{
  275. margin-left: 10rpx;
  276. }
  277. }
  278. }
  279. }
  280. .property{
  281. text-align: center;
  282. .up{
  283. font-size: 32rpx;
  284. font-weight: 600;
  285. color: #333333;
  286. line-height: 45rpx;
  287. /deep/ .u-icon{
  288. display: block;
  289. }
  290. }
  291. .down{
  292. font-size: 26rpx;
  293. font-weight: 400;
  294. color: #666666;
  295. line-height: 37rpx;
  296. }
  297. }
  298. .order-state{
  299. .title{
  300. margin-bottom: 30rpx;
  301. .right{
  302. font-size: 24rpx;
  303. color: #00A447;
  304. }
  305. }
  306. background-color: #fff;
  307. padding: 20rpx;
  308. margin: 0 20rpx 50rpx;
  309. .state{
  310. text-align: center;
  311. /deep/ .u-icon{
  312. display: block;
  313. }
  314. .up{
  315. position: relative;
  316. }
  317. .down{
  318. font-size: 24rpx;
  319. font-weight: 400;
  320. color: #666666;
  321. line-height: 31rpx;
  322. }
  323. }
  324. }
  325. .tools{
  326. .tools-wrap{
  327. background-color: #fff;
  328. padding: 30rpx 0;
  329. border-radius: 8rpx;
  330. }
  331. .tool-item{
  332. margin-left: 40rpx;
  333. text-align: center;
  334. /deep/ .u-icon{
  335. display: block;
  336. }
  337. .down{
  338. font-size: 24rpx;
  339. font-weight: 400;
  340. color: #666666;
  341. line-height: 31rpx;
  342. }
  343. }
  344. .button-item{
  345. background-color: transparent;
  346. line-height: 1;
  347. font-size: 24rpx;
  348. font-weight: 400;
  349. color: #666666;
  350. border: 0;
  351. padding: 0;
  352. top: -2px;
  353. &::after{border: initial;}
  354. }
  355. }
  356. .pay-code-warp{
  357. height: 100vh;
  358. }
  359. </style>