index.vue 6.8 KB

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