鸿宇研学生前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

314 lines
7.1 KiB

3 months ago
  1. <template>
  2. <view class="page__view">
  3. <image class="bg" src="@/static/image/center-bg.png" mode="widthFix"></image>
  4. <view class="main">
  5. <view class="content">
  6. <view class="flex user">
  7. <!-- 用户信息 -->
  8. <template v-if="isLogin">
  9. <view class="user-avatar">
  10. <image class="user-avatar-img" :src="userInfo.avatar" mode="scaleToFill"></image>
  11. </view>
  12. <view class="user-info">
  13. <view class="user-info-name">{{ userInfo.name }}</view>
  14. <view class="user-info-desc">{{ userInfo.phone }}</view>
  15. </view>
  16. </template>
  17. <template v-else>
  18. <view class="user-avatar is-default">
  19. <image class="user-avatar-img" src="@/pages_order/static/center/avatar-default.png" mode="scaleToFill"></image>
  20. </view>
  21. <view class="user-info">
  22. <view class="user-info-tips">暂未登录 请先登录</view>
  23. </view>
  24. </template>
  25. </view>
  26. <!-- 订单信息 -->
  27. <template v-if="isLogin">
  28. <order-card :statistics="statistics"></order-card>
  29. </template>
  30. <!-- 用户菜单 -->
  31. <template v-if="isLogin">
  32. <view class="card">
  33. <view v-for="item in list1" :key="item.id">
  34. <template v-if="item.key === 'service'">
  35. <button plain class="flex btn-service" open-type="contact">
  36. <view class="flex row">
  37. <view class="flex label">
  38. <image class="icon" :src="item.icon" mode="scaleToFill"></image>
  39. <view>{{ item.label }}</view>
  40. </view>
  41. <uv-icon name="arrow-right" color="#C6C6C6" size="24rpx"></uv-icon>
  42. </view>
  43. </button>
  44. </template>
  45. <view v-else class="flex row" @click="onClick(item)">
  46. <view class="flex label">
  47. <image class="icon" :src="item.icon" mode="scaleToFill"></image>
  48. <view>{{ item.label }}</view>
  49. </view>
  50. <uv-icon name="arrow-right" color="#C6C6C6" size="24rpx"></uv-icon>
  51. </view>
  52. </view>
  53. </view>
  54. <view class="card">
  55. <view v-for="item in list2" :key="item.id">
  56. <view class="flex row" @click="onClick(item)">
  57. <view class="flex label">
  58. <image class="icon" :src="item.icon" mode="scaleToFill"></image>
  59. <view>{{ item.label }}</view>
  60. </view>
  61. <uv-icon name="arrow-right" color="#C6C6C6" size="24rpx"></uv-icon>
  62. </view>
  63. </view>
  64. </view>
  65. </template>
  66. <!-- 用户登陆 -->
  67. <template v-else>
  68. <view class="login">
  69. <button class="btn" @click="$utils.toLogin">立即登录</button>
  70. <view class="tips">暂未登录 请先登录</view>
  71. </view>
  72. </template>
  73. </view>
  74. <tabber select="center" />
  75. </view>
  76. </view>
  77. </template>
  78. <script>
  79. import { mapState } from 'vuex'
  80. import tabber from '@/components/base/tabbar.vue'
  81. import orderCard from '@/pages_order/center/orderCard.vue'
  82. export default {
  83. components: {
  84. orderCard,
  85. tabber,
  86. },
  87. data() {
  88. return {
  89. statistics: {},
  90. list1: [
  91. { id: '001', label: '检测预约', icon: '/pages_order/static/center/icon-detectBook.png', path: '/pages_order/checkup/checkupRecords' },
  92. { id: '002', label: '联系客服', icon: '/pages_order/static/center/icon-service.png', key: 'service' },
  93. // todo: check key
  94. { id: '003', label: '服用说明', icon: '/pages_order/static/center/icon-instruc.png', path: `/pages_order/common?key=instruc&title=服用说明` },
  95. // todo: check key
  96. { id: '004', label: '用户须知', icon: '/pages_order/static/center/icon-userAgreement.png', path: `/pages_order/common?key=userAgreement&title=用户须知` },
  97. ],
  98. list2: [
  99. { id: '005', label: '我的评价', icon: '/pages_order/static/center/icon-comment.png', key: 'comment' },
  100. // todo: check key
  101. { id: '006', label: '关于我们', icon: '/pages_order/static/center/icon-aboutUs.png', path: `/pages_order/common?key=aboutUs&title=关于我们` },
  102. { id: '007', label: '修改信息', icon: '/pages_order/static/center/icon-modifyInfo.png', path: `/pages_order/auth/wxUserInfo?mode=edit` },
  103. { id: '008', label: '退出登录', icon: '/pages_order/static/center/icon-logout.png', key: 'logout' },
  104. ],
  105. }
  106. },
  107. computed: {
  108. ...mapState(['userInfo', 'configList']),
  109. isLogin() {
  110. return this.userInfo && this.userInfo.id
  111. }
  112. },
  113. onShow() {
  114. if(uni.getStorageSync('token')){
  115. this.$store.commit('getUserInfo')
  116. this.fetchOrderStatistics()
  117. }
  118. },
  119. methods: {
  120. onClick(target) {
  121. const { key, path } = target
  122. switch(key) {
  123. case 'comment':
  124. this.$utils.navigateTo('/pages_order/comment/commentRecords')
  125. break
  126. case 'logout':
  127. this.$store.commit('logout')
  128. break
  129. default:
  130. path && this.$utils.navigateTo(path)
  131. break
  132. }
  133. },
  134. async fetchOrderStatistics() {
  135. return
  136. try {
  137. this.statistics = await this.$fetch('getOrderStatistics', { id: '' })
  138. } catch (err) {
  139. }
  140. },
  141. },
  142. }
  143. </script>
  144. <style scoped lang="scss">
  145. .page__view {
  146. width: 100vw;
  147. min-height: 100vh;
  148. background-color: $uni-bg-color;
  149. position: relative;
  150. /deep/ .nav-bar__view {
  151. position: fixed;
  152. top: 0;
  153. left: 0;
  154. }
  155. .nav-icon {
  156. width: 200rpx;
  157. height: auto;
  158. vertical-align: top;
  159. }
  160. }
  161. .bg {
  162. width: 100vw;
  163. height: auto;
  164. }
  165. .main {
  166. position: absolute;
  167. top: 176rpx;
  168. left: 0;
  169. width: 100%;
  170. }
  171. .content {
  172. width: 100%;
  173. padding: 16rpx 32rpx 80rpx 32rpx;
  174. box-sizing: border-box;
  175. }
  176. .user {
  177. column-gap: 24rpx;
  178. &-avatar {
  179. flex: none;
  180. width: 100rpx;
  181. height: 100rpx;
  182. border: 4rpx solid #FFFFFF;
  183. border-radius: 50%;
  184. overflow: hidden;
  185. &.is-default {
  186. width: 108rpx;
  187. height: 108rpx;
  188. border: none;
  189. }
  190. &-img {
  191. width: 100%;
  192. height: 100%;
  193. }
  194. }
  195. &-info {
  196. flex: 1;
  197. &-name {
  198. font-family: PingFang SC;
  199. font-weight: 600;
  200. font-size: 36rpx;
  201. line-height: 1.2;
  202. color: #FFFFFF;
  203. }
  204. &-desc {
  205. margin-top: 8rpx;
  206. font-family: PingFang SC;
  207. font-weight: 400;
  208. font-size: 24rpx;
  209. line-height: 1.5;
  210. color: #F4F4F4;
  211. }
  212. &-tips {
  213. font-family: PingFang SC;
  214. font-weight: 400;
  215. font-size: 36rpx;
  216. line-height: 1.2;
  217. color: #FFFFFF;
  218. }
  219. }
  220. }
  221. .card {
  222. margin-top: 32rpx;
  223. width: 100%;
  224. background: #FAFAFF;
  225. border: 2rpx solid #FFFFFF;
  226. border-radius: 32rpx;
  227. box-sizing: border-box;
  228. .row {
  229. justify-content: space-between;
  230. width: 100%;
  231. padding: 40rpx;
  232. box-sizing: border-box;
  233. .label {
  234. font-family: PingFang SC;
  235. font-weight: 400;
  236. font-size: 28rpx;
  237. line-height: 1;
  238. color: #252545;
  239. .icon {
  240. margin-right: 16rpx;
  241. width: 40rpx;
  242. height: 40rpx;
  243. }
  244. }
  245. }
  246. }
  247. .btn-service {
  248. border: none;
  249. padding: 0;
  250. }
  251. .login {
  252. margin-top: 307rpx;
  253. padding: 0 128rpx;
  254. .btn {
  255. padding: 16rpx 0;
  256. font-family: PingFang SC;
  257. font-weight: 500;
  258. font-size: 36rpx;
  259. line-height: 1.4;
  260. color: #FFFFFF;
  261. background-image: linear-gradient(to right, #21FEEC, #019AF9);
  262. border-radius: 41rpx;
  263. }
  264. .tips {
  265. margin-top: 16rpx;
  266. text-align: center;
  267. font-family: PingFang SC;
  268. font-weight: 400;
  269. font-size: 26rpx;
  270. line-height: 1.4;
  271. color: #A3A3A3;
  272. }
  273. }
  274. </style>