index.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  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&&user._id==null">
  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_num||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=='我的尊荣'">{{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_num: '',
  139. // 积分
  140. integral: ''
  141. };
  142. },
  143. onShow: function() {
  144. const that = this;
  145. // 查询其他信息
  146. that.searchOther();
  147. // 监听用户登录
  148. that.watchLogin();
  149. },
  150. methods: {
  151. // 监听用户登录
  152. watchLogin() {
  153. const that = this;
  154. uni.getStorage({
  155. key: 'token',
  156. success: async (res) => {
  157. let user = that.$jwt(res.data);
  158. if (user && user._id) {
  159. let arr;
  160. // 查询用户信息
  161. arr = await that.$api(`/user/${user._id}`, 'GET');
  162. if (arr.errcode == '0') that.$set(that, `user`, arr.data);
  163. // 查询收藏商品
  164. arr = await that.$api(`/storeGoods/userView`, 'GET', {
  165. customer: user._id
  166. })
  167. if (arr.errcode == '0') that.$set(that, `market_num`, arr.total);
  168. // 查询收藏店铺
  169. arr = await that.$api(`/storeShop/userView`, 'GET', {
  170. customer: user._id
  171. })
  172. if (arr.errcode == '0') that.$set(that, `shop_num`, arr.total);
  173. arr = await that.$api(`/point/computedTotal`, 'GET', {
  174. customer: user._id
  175. })
  176. if (arr.errcode == '0') that.$set(that, `integral`, Math.trunc(arr.data));
  177. }
  178. },
  179. fail: (err) => {}
  180. })
  181. },
  182. // 查询其他信息
  183. async searchOther() {
  184. const that = this;
  185. let res;
  186. res = await that.$api(`/serviceContact`, 'GET');
  187. if (res.errcode == '0' && res.total > 0) {
  188. that.$set(that, `serviceContactInfo`, res.data[0])
  189. }
  190. },
  191. // 底部菜单跳转
  192. toPath(e) {
  193. if (e && e.route && e.type == '0') {
  194. uni.redirectTo({
  195. url: `/${e.route}`
  196. })
  197. } else {
  198. uni.navigateTo({
  199. url: `/${e.route}`
  200. })
  201. }
  202. },
  203. // 公共跳转
  204. toCommon(e) {
  205. uni.getStorage({
  206. key: 'token',
  207. success: function(res) {
  208. uni.navigateTo({
  209. url: `/${e}`
  210. })
  211. },
  212. fail: function(err) {
  213. uni.navigateTo({
  214. url: `/pages/login/index`
  215. })
  216. }
  217. });
  218. },
  219. // 订单跳转页面
  220. toOrder(e) {
  221. const that = this;
  222. uni.getStorage({
  223. key: 'token',
  224. success: function(res) {
  225. if (e.type == 'order') {
  226. uni.navigateTo({
  227. url: `/${e.route}?status=${e.status}`
  228. })
  229. } else if (e.type == 'after') {
  230. uni.navigateTo({
  231. url: `/${e.route}`
  232. })
  233. }
  234. },
  235. fail: function(err) {
  236. uni.navigateTo({
  237. url: `/pages/login/index`
  238. })
  239. }
  240. });
  241. },
  242. // 拨打电话
  243. makePhone(e) {
  244. uni.makePhoneCall({
  245. phoneNumber: e
  246. });
  247. }
  248. }
  249. }
  250. </script>
  251. <style lang="scss">
  252. .main {
  253. display: flex;
  254. flex-direction: column;
  255. width: 100vw;
  256. height: 100vh;
  257. .one {
  258. text-align: center;
  259. padding: 4vw 0;
  260. background-color: var(--fFB1Color);
  261. color: var(--mainColor);
  262. .one_1 {
  263. margin: 0 0 5vw 0;
  264. image {
  265. width: 25vw;
  266. height: 25vw;
  267. border-radius: 25vw;
  268. }
  269. .iconfont {
  270. font-size: 80px;
  271. }
  272. .name {
  273. display: flex;
  274. justify-content: space-evenly;
  275. margin: 2vw 0;
  276. font-size: var(--font18Szie);
  277. }
  278. .image {
  279. border: 1px solid var(--f1Color);
  280. }
  281. }
  282. .one_2 {
  283. display: flex;
  284. flex-direction: row;
  285. justify-content: space-around;
  286. font-size: var(--font16Szie);
  287. .one_2_1 {
  288. display: flex;
  289. flex-direction: column;
  290. }
  291. .link {
  292. font-weight: bold;
  293. }
  294. }
  295. }
  296. .two {
  297. background-color: var(--f1Color);
  298. .two_1 {
  299. display: flex;
  300. justify-content: space-between;
  301. padding: 4vw;
  302. background-color: var(--mainColor);
  303. margin: 0 0 0.1vw 0;
  304. border-bottom: 1px solid var(--f1Color);
  305. .title {
  306. font-size: var(--font16Szie);
  307. text:first-child {
  308. margin: 0 1vw 0 0;
  309. }
  310. }
  311. .title:last-child {
  312. color: var(--f85Color);
  313. font-size: var(--font14Size);
  314. }
  315. }
  316. .two_1:nth-last-child(2) {
  317. margin: 0 0 2vw 0;
  318. }
  319. .two_1:nth-last-child(4) {
  320. margin: 0 0 2vw 0;
  321. }
  322. .two_2 {
  323. display: flex;
  324. justify-content: space-between;
  325. padding: 5vw;
  326. background-color: var(--mainColor);
  327. margin: 0 0 2vw 0;
  328. .orderList {
  329. text-align: center;
  330. .icon {
  331. .iconfont {
  332. font-size: 25px;
  333. }
  334. }
  335. .title {
  336. display: inline-block;
  337. margin: 2vw 0 0 0;
  338. font-size: var(--font12Size);
  339. }
  340. }
  341. }
  342. }
  343. }
  344. </style>