index.vue 5.7 KB

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