index.vue 7.6 KB

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