index.vue 7.9 KB

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