index.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  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. <uni-badge :text="item.num" absolute="rightTop" size="normal">
  39. <view class="icon">
  40. <text class="iconfont" :class="[item.icon]"></text>
  41. </view>
  42. <text class="title">{{item.title}}</text>
  43. </uni-badge>
  44. </view>
  45. </view>
  46. <view class="two_1" v-for="(item, index) in menuList" :key="index" @click="toCommon(item.route)">
  47. <view class="title">{{item.title}}</view>
  48. <view class="title">
  49. <text v-if="user.id&&item.title=='我的尊荣'">{{integral||0}}分</text>
  50. <text v-if="item.title=='客服电话'"
  51. @tap="makePhone(serviceContactInfo.phone)">{{serviceContactInfo.phone||''}}</text>
  52. <text class="iconfont icon-jiantouyou"></text>
  53. </view>
  54. </view>
  55. </view>
  56. </view>
  57. </mobile-frame>
  58. </template>
  59. <script>
  60. export default {
  61. data() {
  62. return {
  63. frameStyle: {
  64. useBar: true
  65. },
  66. // 用户信息
  67. user: {},
  68. // 客服信息
  69. serviceContactInfo: {},
  70. // 订单图标菜单
  71. orderList: [],
  72. // 菜单
  73. menuList: [],
  74. // 收藏商品
  75. market_num: '',
  76. // 收藏店铺
  77. shop_num: '',
  78. // 积分
  79. integral: ''
  80. };
  81. },
  82. onShow: function() {
  83. const that = this;
  84. // 查询其他信息
  85. that.searchOther();
  86. // 监听用户登录
  87. that.watchLogin();
  88. },
  89. methods: {
  90. // 监听用户登录
  91. watchLogin() {
  92. const that = this;
  93. uni.getStorage({
  94. key: 'token',
  95. success: async (res) => {
  96. let user = that.$jwt(res.data);
  97. if (user && user._id) {
  98. let arr;
  99. // 查询用户信息
  100. arr = await that.$api(`/user/${user._id}`, 'GET');
  101. if (arr.errcode == '0') that.$set(that, `user`, arr.data);
  102. // 查询收藏商品
  103. arr = await that.$api(`/storeGoods/userView`, 'GET', {
  104. customer: user._id
  105. })
  106. if (arr.errcode == '0') that.$set(that, `market_num`, arr.total);
  107. // 查询收藏店铺
  108. arr = await that.$api(`/storeShop/userView`, 'GET', {
  109. customer: user._id
  110. })
  111. if (arr.errcode == '0') that.$set(that, `shop_num`, arr.total);
  112. arr = await that.$api(`/point/computedTotal`, 'GET', {
  113. customer: user._id
  114. })
  115. if (arr.errcode == '0') that.$set(that, `integral`, Math.trunc(arr.data));
  116. that.searchOther();
  117. }
  118. },
  119. fail: (err) => {}
  120. })
  121. },
  122. // 查询其他信息
  123. async searchOther() {
  124. const that = this;
  125. let config = that.$config;
  126. let user = that.user;
  127. if (config) {
  128. if (user && user._id) {
  129. let res = await that.$api(`/viewUser/toDeal`, 'GET');
  130. if (res.errcode == '0') {
  131. for (let val of config.my_orderList) {
  132. if (val.type == "order") {
  133. if (val.status == '0') val.num = res.data.notPay
  134. if (val.status == '1') val.num = res.data.isPay
  135. if (val.status == '2') val.num = res.data.allSend
  136. } else {
  137. val.num = res.data.afterSale;
  138. }
  139. }
  140. }
  141. }
  142. // 订单图标菜单
  143. that.$set(that, `orderList`, config.my_orderList);
  144. // 菜单
  145. that.$set(that, `menuList`, config.my_menu);
  146. }
  147. let res;
  148. res = await that.$api(`/serviceContact`, 'GET');
  149. if (res.errcode == '0' && res.total > 0) {
  150. that.$set(that, `serviceContactInfo`, res.data[0])
  151. }
  152. },
  153. // 公共跳转
  154. toCommon(e) {
  155. uni.getStorage({
  156. key: 'token',
  157. success: function(res) {
  158. uni.navigateTo({
  159. url: `/${e}`
  160. })
  161. },
  162. fail: function(err) {
  163. uni.navigateTo({
  164. url: `/pages/login/index`
  165. })
  166. }
  167. });
  168. },
  169. // 订单跳转页面
  170. toOrder(e) {
  171. const that = this;
  172. uni.getStorage({
  173. key: 'token',
  174. success: function(res) {
  175. if (e.type == 'order') {
  176. uni.navigateTo({
  177. url: `/${e.route}?status=${e.status}`
  178. })
  179. } else if (e.type == 'after') {
  180. uni.navigateTo({
  181. url: `/${e.route}`
  182. })
  183. }
  184. },
  185. fail: function(err) {
  186. uni.navigateTo({
  187. url: `/pages/login/index`
  188. })
  189. }
  190. });
  191. },
  192. // 拨打电话
  193. makePhone(e) {
  194. uni.makePhoneCall({
  195. phoneNumber: e
  196. });
  197. },
  198. // 底部菜单跳转
  199. toPath(e) {
  200. let url = `/${e.route}`;
  201. if (e.type == '0') uni.redirectTo({
  202. url
  203. })
  204. else {
  205. uni.navigateTo({
  206. url
  207. })
  208. }
  209. },
  210. }
  211. }
  212. </script>
  213. <style lang="scss">
  214. .main {
  215. display: flex;
  216. flex-direction: column;
  217. width: 100vw;
  218. height: 100vh;
  219. .one {
  220. text-align: center;
  221. padding: 4vw 0;
  222. background-color: var(--fFB1Color);
  223. color: var(--mainColor);
  224. .one_1 {
  225. margin: 0 0 5vw 0;
  226. image {
  227. width: 25vw;
  228. height: 25vw;
  229. border-radius: 25vw;
  230. }
  231. .iconfont {
  232. font-size: 80px;
  233. }
  234. .name {
  235. display: flex;
  236. justify-content: space-evenly;
  237. margin: 2vw 0;
  238. font-size: var(--font18Szie);
  239. }
  240. .image {
  241. border: 1px solid var(--f1Color);
  242. }
  243. }
  244. .one_2 {
  245. display: flex;
  246. flex-direction: row;
  247. justify-content: space-around;
  248. font-size: var(--font16Szie);
  249. .one_2_1 {
  250. display: flex;
  251. flex-direction: column;
  252. }
  253. .link {
  254. font-weight: bold;
  255. }
  256. }
  257. }
  258. .two {
  259. background-color: var(--f1Color);
  260. .two_1 {
  261. display: flex;
  262. justify-content: space-between;
  263. padding: 4vw;
  264. background-color: var(--mainColor);
  265. margin: 0 0 0.1vw 0;
  266. border-bottom: 1px solid var(--f1Color);
  267. .title {
  268. font-size: var(--font16Szie);
  269. text:first-child {
  270. margin: 0 1vw 0 0;
  271. }
  272. }
  273. .title:last-child {
  274. color: var(--f85Color);
  275. font-size: var(--font14Size);
  276. }
  277. }
  278. .two_1:nth-last-child(2) {
  279. margin: 0 0 2vw 0;
  280. }
  281. .two_1:nth-last-child(4) {
  282. margin: 0 0 2vw 0;
  283. }
  284. .two_2 {
  285. display: flex;
  286. justify-content: space-between;
  287. padding: 5vw;
  288. background-color: var(--mainColor);
  289. margin: 0 0 2vw 0;
  290. .orderList {
  291. text-align: center;
  292. .icon {
  293. .iconfont {
  294. font-size: 25px;
  295. }
  296. }
  297. .title {
  298. display: inline-block;
  299. margin: 2vw 0 0 0;
  300. font-size: var(--font12Size);
  301. }
  302. }
  303. }
  304. }
  305. }
  306. </style>