index.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. <template>
  2. <mobile-frame :frameStyle="frameStyle" @toPath="toPath">
  3. <view class="main">
  4. <view class="one">
  5. <view class="one_1" v-if="!user._id">
  6. <text class="iconfont icon-geren2" @click="toCommon('pages/login/index')"></text>
  7. <view class="name">未登录</view>
  8. </view>
  9. <view class="one_1" v-else>
  10. <image class="image" :src="user.icon&&user.icon.length>0?user.icon[0].url:''"></image>
  11. <view class="name">
  12. <text>{{user.name||'暂无名称'}}</text>
  13. <text>普通会员</text>
  14. </view>
  15. </view>
  16. <view class="one_2">
  17. <view class="one_2_1">
  18. <text v-if="user._id">{{user.collect||0}}</text>
  19. <text @click="toCommon('pagesMy/collection/market')">收藏的商品</text>
  20. </view>
  21. <text class="link">|</text>
  22. <view class="one_2_1">
  23. <text v-if="user._id">{{user.collect||0}}</text>
  24. <text @click="toCommon('pagesMy/collection/shop')">收藏的店铺</text>
  25. </view>
  26. </view>
  27. </view>
  28. <view class="two">
  29. <view class="two_1">
  30. <view class="title">我的订单</view>
  31. <view class="title">
  32. <text @click="toCommon('pagesMy/order/index')">全部订单</text>
  33. <text class="iconfont icon-dayufuhao"></text>
  34. </view>
  35. </view>
  36. <view class="two_2">
  37. <view class="orderList" v-for="(item, index) in orderList" :key="index" @click="toOrrder(item.type)">
  38. <view class="icon">
  39. <text class="iconfont" :class="[item.icon]"></text>
  40. </view>
  41. <text class="title">{{item.title}}</text>
  42. </view>
  43. </view>
  44. <view class="two_1" v-for="(item, index) in menuList" :key="index" @click="toCommon(item.route)">
  45. <view class="title">{{item.title}}</view>
  46. <view class="title">
  47. <text v-if="user.id&&item.title=='我的积分'">{{user.integral||0}}分</text>
  48. <text v-if="item.title=='客服电话'">{{serviceContaceInfo.phone||''}}</text>
  49. <text class="iconfont icon-dayufuhao"></text>
  50. </view>
  51. </view>
  52. </view>
  53. </view>
  54. </mobile-frame>
  55. </template>
  56. <script>
  57. export default {
  58. data() {
  59. return {
  60. frameStyle: {
  61. useBar: true
  62. },
  63. // 用户信息
  64. user: {},
  65. // 客服信息
  66. serviceContaceInfo: {},
  67. // 图标菜单
  68. orderList: [{
  69. icon: 'icon-daifukuan',
  70. title: '待付款',
  71. type: 'a'
  72. },
  73. {
  74. icon: 'icon-daifahuo',
  75. title: '待发货',
  76. type: 'b'
  77. },
  78. {
  79. icon: 'icon-daishouhuo',
  80. title: '待收货/消费',
  81. type: 'c'
  82. },
  83. {
  84. icon: 'icon-daipinglun',
  85. title: '待评论',
  86. type: 'd'
  87. },
  88. {
  89. icon: 'icon-shouhoufuwuicon',
  90. title: '售后',
  91. type: 'e'
  92. },
  93. ],
  94. // 菜单
  95. menuList: [{
  96. title: '我的优惠劵',
  97. route: 'pagesMy/discount/index'
  98. },
  99. {
  100. title: '我的积分',
  101. route: 'pagesMy/integral/index'
  102. },
  103. {
  104. title: '我的资产',
  105. route: 'pagesMy/assets/index'
  106. },
  107. {
  108. title: '我的拼团',
  109. route: 'pagesMy/dough/index'
  110. },
  111. {
  112. title: '我的收货地址',
  113. route: 'pagesMy/address/index'
  114. },
  115. {
  116. title: '账号管理',
  117. route: 'pagesMy/account/index'
  118. },
  119. {
  120. title: '客服电话',
  121. route: ''
  122. },
  123. ],
  124. };
  125. },
  126. onShow: async function() {
  127. const that = this;
  128. // 查询其他信息
  129. await that.searchOther();
  130. // 监听用户登录
  131. await that.watchLogin();
  132. },
  133. methods: {
  134. watchLogin() {
  135. const that = this;
  136. uni.getStorage({
  137. key: 'token',
  138. success: async (res) => {
  139. let user = that.$jwt(res.data);
  140. const arr = await that.$api(`/user/${user.id}`, 'GET');
  141. if (arr.errcode == '0') that.$set(that, `user`, arr.data);
  142. },
  143. fail: (err) => {}
  144. })
  145. },
  146. // 查询其他信息
  147. async searchOther() {
  148. const that = this;
  149. let res;
  150. res = await that.$api(`/serviceContace`, 'GET');
  151. if (res.errcode == '0' && res.total > 0) {
  152. that.$set(that, `serviceContaceInfo`, res.data[0])
  153. }
  154. },
  155. toPath(e) {
  156. if (e && e.route) uni.redirectTo({
  157. url: `/${e.route}`
  158. })
  159. },
  160. // 公共跳转
  161. toCommon(e) {
  162. uni.getStorage({
  163. key: 'token',
  164. success: function(res) {
  165. uni.navigateTo({
  166. url: `/${e}`
  167. })
  168. },
  169. fail: function(err) {
  170. uni.navigateTo({
  171. url: `/pages/login/index`
  172. })
  173. }
  174. });
  175. },
  176. // 跳转页面
  177. toOrrder(e) {
  178. const that = this;
  179. uni.navigateTo({
  180. url: `/${e}`
  181. })
  182. },
  183. }
  184. }
  185. </script>
  186. <style lang="scss">
  187. .main {
  188. display: flex;
  189. flex-direction: column;
  190. width: 100vw;
  191. height: 100vh;
  192. .one {
  193. text-align: center;
  194. padding: 4vw 0;
  195. background-color: var(--fFB1Color);
  196. color: var(--mainColor);
  197. .one_1 {
  198. margin: 0 0 5vw 0;
  199. image {
  200. width: 25vw;
  201. height: 25vw;
  202. border-radius: 25vw;
  203. }
  204. .iconfont {
  205. font-size: 80px;
  206. }
  207. .name {
  208. display: flex;
  209. justify-content: space-evenly;
  210. margin: 2vw 0;
  211. font-size: var(--font18Szie);
  212. }
  213. .image {
  214. border: 1px solid var(--f1Color);
  215. }
  216. }
  217. .one_2 {
  218. display: flex;
  219. flex-direction: row;
  220. justify-content: space-around;
  221. font-size: var(--font16Szie);
  222. .one_2_1 {
  223. display: flex;
  224. flex-direction: column;
  225. }
  226. .link {
  227. font-weight: bold;
  228. }
  229. }
  230. }
  231. .two {
  232. background-color: var(--f1Color);
  233. .two_1 {
  234. display: flex;
  235. justify-content: space-between;
  236. padding: 4vw;
  237. background-color: var(--mainColor);
  238. margin: 0 0 0.1vw 0;
  239. .title {
  240. font-size: var(--font16Szie);
  241. text:first-child {
  242. margin: 0 1vw 0 0;
  243. }
  244. }
  245. .title:last-child {
  246. color: var(--f85Color);
  247. font-size: var(--font14Size);
  248. }
  249. }
  250. .two_1:nth-last-child(2) {
  251. margin: 0 0 2vw 0;
  252. }
  253. .two_1:nth-last-child(4) {
  254. margin: 0 0 2vw 0;
  255. }
  256. .two_2 {
  257. display: flex;
  258. justify-content: space-between;
  259. padding: 5vw;
  260. background-color: var(--mainColor);
  261. margin: 0 0 2vw 0;
  262. .orderList {
  263. text-align: center;
  264. .icon {
  265. .iconfont {
  266. font-size: 25px;
  267. }
  268. }
  269. .title {
  270. display: inline-block;
  271. margin: 2vw 0 0 0;
  272. font-size: var(--font12Size);
  273. }
  274. }
  275. }
  276. }
  277. }
  278. </style>