index.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  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="toOrder({route:'pagesMy/order/index',type:'order',status:'0'})">全部订单</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="toOrder(item)">
  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. {
  70. icon: 'icon-daifukuan',
  71. title: '待付款',
  72. status: '1',
  73. type: 'order',
  74. route: "pagesMy/order/index",
  75. },
  76. {
  77. icon: 'icon-daifahuo',
  78. title: '待发货',
  79. status: '2',
  80. type: 'order',
  81. route: "pagesMy/order/index",
  82. },
  83. {
  84. icon: 'icon-daishouhuo',
  85. title: '待收货/消费',
  86. status: '3',
  87. type: 'order',
  88. route: "pagesMy/order/index",
  89. },
  90. {
  91. icon: 'icon-daipinglun',
  92. title: '待评论',
  93. status: '4',
  94. type: 'order',
  95. route: "pagesMy/order/index",
  96. },
  97. {
  98. icon: 'icon-shouhoufuwuicon',
  99. title: '售后',
  100. type: 'after',
  101. route: "pagesMy/order/after",
  102. },
  103. ],
  104. // 菜单
  105. menuList: [{
  106. title: '我的优惠劵',
  107. route: 'pagesMy/discount/index'
  108. },
  109. {
  110. title: '我的积分',
  111. route: 'pagesMy/integral/index'
  112. },
  113. {
  114. title: '我的资产',
  115. route: 'pagesMy/assets/index'
  116. },
  117. {
  118. title: '我的拼团',
  119. route: 'pagesMy/dough/index'
  120. },
  121. {
  122. title: '我的收货地址',
  123. route: 'pagesMy/address/index'
  124. },
  125. {
  126. title: '账号管理',
  127. route: 'pagesMy/account/index'
  128. },
  129. {
  130. title: '客服电话',
  131. route: ''
  132. },
  133. ],
  134. };
  135. },
  136. onShow: async function() {
  137. const that = this;
  138. // 查询其他信息
  139. await that.searchOther();
  140. // 监听用户登录
  141. await that.watchLogin();
  142. },
  143. methods: {
  144. // 监听用户登录
  145. watchLogin() {
  146. const that = this;
  147. uni.getStorage({
  148. key: 'token',
  149. success: async (res) => {
  150. let user = that.$jwt(res.data);
  151. const arr = await that.$api(`/user/${user.id}`, 'GET');
  152. if (arr.errcode == '0') that.$set(that, `user`, arr.data);
  153. },
  154. fail: (err) => {}
  155. })
  156. },
  157. // 查询其他信息
  158. async searchOther() {
  159. const that = this;
  160. let res;
  161. res = await that.$api(`/serviceContace`, 'GET');
  162. if (res.errcode == '0' && res.total > 0) {
  163. that.$set(that, `serviceContaceInfo`, res.data[0])
  164. }
  165. },
  166. // 底部菜单跳转
  167. toPath(e) {
  168. if (e && e.route) uni.redirectTo({
  169. url: `/${e.route}`
  170. })
  171. },
  172. // 公共跳转
  173. toCommon(e) {
  174. uni.getStorage({
  175. key: 'token',
  176. success: function(res) {
  177. uni.navigateTo({
  178. url: `/${e}`
  179. })
  180. },
  181. fail: function(err) {
  182. uni.navigateTo({
  183. url: `/pages/login/index`
  184. })
  185. }
  186. });
  187. },
  188. // 订单跳转页面
  189. toOrder(e) {
  190. if (e.type == 'order') {
  191. uni.navigateTo({
  192. url: `/${e.route}?status=${e.status}`
  193. })
  194. } else if (e.type == 'after') {
  195. uni.navigateTo({
  196. url: `/${e.route}`
  197. })
  198. }
  199. },
  200. }
  201. }
  202. </script>
  203. <style lang="scss">
  204. .main {
  205. display: flex;
  206. flex-direction: column;
  207. width: 100vw;
  208. height: 100vh;
  209. .one {
  210. text-align: center;
  211. padding: 4vw 0;
  212. background-color: var(--fFB1Color);
  213. color: var(--mainColor);
  214. .one_1 {
  215. margin: 0 0 5vw 0;
  216. image {
  217. width: 25vw;
  218. height: 25vw;
  219. border-radius: 25vw;
  220. }
  221. .iconfont {
  222. font-size: 80px;
  223. }
  224. .name {
  225. display: flex;
  226. justify-content: space-evenly;
  227. margin: 2vw 0;
  228. font-size: var(--font18Szie);
  229. }
  230. .image {
  231. border: 1px solid var(--f1Color);
  232. }
  233. }
  234. .one_2 {
  235. display: flex;
  236. flex-direction: row;
  237. justify-content: space-around;
  238. font-size: var(--font16Szie);
  239. .one_2_1 {
  240. display: flex;
  241. flex-direction: column;
  242. }
  243. .link {
  244. font-weight: bold;
  245. }
  246. }
  247. }
  248. .two {
  249. background-color: var(--f1Color);
  250. .two_1 {
  251. display: flex;
  252. justify-content: space-between;
  253. padding: 4vw;
  254. background-color: var(--mainColor);
  255. margin: 0 0 0.1vw 0;
  256. .title {
  257. font-size: var(--font16Szie);
  258. text:first-child {
  259. margin: 0 1vw 0 0;
  260. }
  261. }
  262. .title:last-child {
  263. color: var(--f85Color);
  264. font-size: var(--font14Size);
  265. }
  266. }
  267. .two_1:nth-last-child(2) {
  268. margin: 0 0 2vw 0;
  269. }
  270. .two_1:nth-last-child(4) {
  271. margin: 0 0 2vw 0;
  272. }
  273. .two_2 {
  274. display: flex;
  275. justify-content: space-between;
  276. padding: 5vw;
  277. background-color: var(--mainColor);
  278. margin: 0 0 2vw 0;
  279. .orderList {
  280. text-align: center;
  281. .icon {
  282. .iconfont {
  283. font-size: 25px;
  284. }
  285. }
  286. .title {
  287. display: inline-block;
  288. margin: 2vw 0 0 0;
  289. font-size: var(--font12Size);
  290. }
  291. }
  292. }
  293. }
  294. }
  295. </style>