center.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  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="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="up">
  75. <u-icon :name="item.ico" color="#333333" size="60rpx"></u-icon>
  76. </view>
  77. <view class="down">{{item.name}}</view>
  78. </view>
  79. </view>
  80. </view>
  81. <!-- <u-overlay :show="showPayCode" @click="showPayCode = false">
  82. <view class="pay-code-warp u-flex u-row-center">
  83. <view class="rect" @tap.stop>
  84. <u--image :showLoading="true" :src="payCodeImg" width="180px" height="180px"></u--image>
  85. </view>
  86. </view>
  87. </u-overlay> -->
  88. <tabbar :tabbarIndexProps="2" />
  89. </view>
  90. </template>
  91. <script>
  92. import { systemInfo } from "@/mixin.js";
  93. import tabbar from "../components/tabbar.vue"
  94. export default {
  95. components:{
  96. tabbar
  97. },
  98. mixins:[systemInfo],
  99. data() {
  100. return {
  101. staticUrl:this.$commonConfig.staticUrl,
  102. avatar:this.$commonConfig.staticUrl+'/img/avatar.png',
  103. showPayCode:false,
  104. payCodeImg:'https://cdn.uviewui.com/uview/album/1.jpg',
  105. memberInfo:{},
  106. orderState:[
  107. // {name:'全部订单',status:'',ico:this.$commonConfig.staticUrl+'/img/orderstateico-all.png'},
  108. {name:'待付款',status:'0',ico:this.$commonConfig.staticUrl+'/img/orderstateico-01.png',badge:'noPayNum'},
  109. {name:'待发货',status:'1',ico:this.$commonConfig.staticUrl+'/img/orderstateico-all.png',badge:'deliverNum'},
  110. {name:'待收货',status:'2',ico:this.$commonConfig.staticUrl+'/img/orderstateico-02.png',badge:'collectNum'},
  111. {name:'待评价',status:'3',ico:this.$commonConfig.staticUrl+'/img/orderstateico-03.png',badge:'commentNum'},
  112. {name:'退款/售后',status:'7',ico:this.$commonConfig.staticUrl+'/img/orderstateico-04.png',badge:'refundNum'},
  113. ],
  114. orderBadge:{
  115. noPayNum:'0',
  116. deliverNum:'0',
  117. collectNum:'0',
  118. commentNum:'0',
  119. refundNum:'0',
  120. },
  121. tools:[
  122. // {name:'充值中心',url:'/center/recharge',ico:this.$commonConfig.staticUrl+'/img/tool-chongzhi.png'},
  123. {name:'地址管理',url:'center/addrlist',ico:this.$commonConfig.staticUrl+'/img/tool-map.png',checkauth:true},
  124. {name:'客服电话',phone:'',ico:this.$commonConfig.staticUrl+'/img/tool-phone.png'},
  125. ]
  126. }
  127. },
  128. onShow() {
  129. if(this.vuex_member_info.name){
  130. this.getMemberInfo();
  131. this.statisticsOrder();
  132. }
  133. },
  134. onLoad() {
  135. this.getSystemInfo();
  136. },
  137. methods: {
  138. getMemberInfo(){
  139. this.$u.api.memberInfo({id:this.vuex_member_info.id}).then(res=>{
  140. this.memberInfo = res.data;
  141. this.avatar = res.data.avatar;
  142. this.$u.vuex('vuex_member_info', res.data);
  143. // console.log('memberInfo',this.memberInfo);
  144. }).catch(err=>{
  145. console.log('memberInfo',err.data);
  146. })
  147. },
  148. toolsClick(item){
  149. let that = this;
  150. console.log('item',item);
  151. if ('phone' in item) {
  152. if(!that.memberInfo.customerMobile){
  153. uni.showToast({
  154. title:'电话号码为空',
  155. icon:"none"
  156. })
  157. return
  158. }
  159. uni.makePhoneCall({
  160. phoneNumber: that.memberInfo.customerMobile,
  161. success() {
  162. console.log('success');
  163. },
  164. fail() {
  165. console.log('fail');
  166. }
  167. });
  168. return
  169. }
  170. if(item.checkauth){
  171. this.checkauth(item.url)
  172. }else{
  173. uni.$u.route(item.url);
  174. }
  175. },
  176. orderClick(item,index){
  177. console.log('item',item);
  178. uni.$u.route('/shopping/order', {
  179. // current: index,
  180. status: item.status,
  181. type: 'redirectTo'
  182. });
  183. },
  184. statisticsOrder(){
  185. this.$u.api.statisticsOrder().then(res=>{
  186. let data = res.data || {};
  187. this.orderBadge = Object.assign(this.orderBadge,data)
  188. // console.log('statisticsOrder',res.data);
  189. // console.log('this.orderBadge',this.orderBadge);
  190. }).catch(err=>{
  191. console.log('memberInfo',err.data);
  192. })
  193. },
  194. goLogin(){
  195. uni.setStorage({
  196. key: 'backUrl',
  197. data:'center/center' ,
  198. success: function () {
  199. uni.$u.route('/pages/login/login')
  200. }
  201. });
  202. },
  203. checkauth(pageUrl){
  204. if(this.vuex_member_info.name){
  205. uni.$u.route(pageUrl)
  206. }else{
  207. uni.showModal({
  208. title: '提示',
  209. content: '你需要登录后,才可使用此功能!',
  210. success: res => {
  211. if (res.confirm) {
  212. uni.setStorage({
  213. key: 'backUrl',
  214. data:pageUrl ,
  215. success: function () {
  216. uni.$u.route('/pages/login/login')
  217. }
  218. });
  219. }
  220. }
  221. })
  222. }
  223. }
  224. }
  225. }
  226. </script>
  227. <style>
  228. page{
  229. background-color: #F5F5F5;
  230. padding-top: 0;
  231. }
  232. </style>
  233. <style lang="scss" scoped>
  234. .title{
  235. font-size: 32rpx;
  236. font-weight: 600;
  237. color: #333333;
  238. line-height: 45rpx;
  239. margin-bottom: 30rpx;
  240. }
  241. .base-info{
  242. margin-bottom: 10rpx;
  243. .info{
  244. margin-left: 30rpx;
  245. .name{
  246. font-size: 40rpx;
  247. font-weight: 600;
  248. color: #333333;
  249. line-height: 56rpx;
  250. margin-bottom: 10rpx;
  251. }
  252. .level{
  253. width: fit-content;
  254. background: linear-gradient(131deg, #FFF2DB 0%, #FFD9A5 100%);
  255. border-radius: 2px;
  256. font-size: 22rpx;
  257. font-weight: 400;
  258. color: #333333;
  259. line-height: 30rpx;
  260. padding: 6rpx 16rpx;
  261. .level-name{
  262. margin-left: 10rpx;
  263. }
  264. }
  265. }
  266. }
  267. .property{
  268. text-align: center;
  269. .up{
  270. font-size: 32rpx;
  271. font-weight: 600;
  272. color: #333333;
  273. line-height: 45rpx;
  274. /deep/ .u-icon{
  275. display: block;
  276. }
  277. }
  278. .down{
  279. font-size: 26rpx;
  280. font-weight: 400;
  281. color: #666666;
  282. line-height: 37rpx;
  283. }
  284. }
  285. .order-state{
  286. .title{
  287. margin-bottom: 30rpx;
  288. .right{
  289. font-size: 24rpx;
  290. color: #00A447;
  291. }
  292. }
  293. background-color: #fff;
  294. padding: 20rpx;
  295. margin: 0 20rpx 50rpx;
  296. .state{
  297. text-align: center;
  298. /deep/ .u-icon{
  299. display: block;
  300. }
  301. .up{
  302. position: relative;
  303. }
  304. .down{
  305. font-size: 24rpx;
  306. font-weight: 400;
  307. color: #666666;
  308. line-height: 31rpx;
  309. }
  310. }
  311. }
  312. .tools{
  313. .tool-item{
  314. margin-left: 40rpx;
  315. text-align: center;
  316. /deep/ .u-icon{
  317. display: block;
  318. }
  319. .down{
  320. font-size: 24rpx;
  321. font-weight: 400;
  322. color: #666666;
  323. line-height: 31rpx;
  324. }
  325. }
  326. }
  327. .pay-code-warp{
  328. height: 100vh;
  329. }
  330. </style>