index.vue 5.7 KB

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