鸿宇研学生前端代码
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.

367 lines
8.2 KiB

  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. <!-- todo: check key -->
  11. <image class="user-avatar-img" src="@/static/image/temp-30.png" mode="scaleToFill"></image>
  12. </view>
  13. <view class="user-info">
  14. <!-- todo: check key -->
  15. <view class="flex user-info-name">
  16. <view class="highligt">战斗世界</view>
  17. <view class="light">ID5625354</view>
  18. </view>
  19. <!-- todo: check key -->
  20. <view class="user-info-desc">手机号19989674531</view>
  21. </view>
  22. </template>
  23. <template v-else>
  24. <view class="user-avatar is-default">
  25. <image class="user-avatar-img" src="@/pages_order/static/center/avatar-default.png" mode="scaleToFill"></image>
  26. </view>
  27. <view class="user-info">
  28. <view class="user-info-tips">暂未登录 请先登录</view>
  29. </view>
  30. </template>
  31. </view>
  32. <template v-if="isLogin">
  33. <view class="flex card member-bind">
  34. <view class="left">成员绑定</view>
  35. <view class="flex right">
  36. <button class="btn" @click="jumpToBindMember">绑定</button>
  37. <uv-icon name="arrow-right" color="#C6C6C6" size="24rpx"></uv-icon>
  38. </view>
  39. </view>
  40. <!-- 订单信息 -->
  41. <order-card :statistics="statistics"></order-card>
  42. <!-- 用户菜单 -->
  43. <view class="card">
  44. <view v-for="item in list1" :key="item.id">
  45. <template v-if="item.key === 'service'">
  46. <button plain class="flex btn-service" open-type="contact">
  47. <view class="flex row">
  48. <view class="flex label">
  49. <image class="icon" :src="item.icon" mode="scaleToFill"></image>
  50. <view>{{ item.label }}</view>
  51. </view>
  52. <uv-icon name="arrow-right" color="#C6C6C6" size="24rpx"></uv-icon>
  53. </view>
  54. </button>
  55. </template>
  56. <view v-else 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. <view class="card">
  66. <view v-for="item in list2" :key="item.id">
  67. <view class="flex row" @click="onClick(item)">
  68. <view class="flex label">
  69. <image class="icon" :src="item.icon" mode="scaleToFill"></image>
  70. <view>{{ item.label }}</view>
  71. </view>
  72. <uv-icon name="arrow-right" color="#C6C6C6" size="24rpx"></uv-icon>
  73. </view>
  74. </view>
  75. </view>
  76. </template>
  77. <!-- 用户登陆 -->
  78. <template v-else>
  79. <view class="login">
  80. <button class="btn" @click="$utils.toLogin">立即登录</button>
  81. <view class="tips">暂未登录 请先登录</view>
  82. </view>
  83. </template>
  84. </view>
  85. <tabber select="center" />
  86. </view>
  87. </view>
  88. </template>
  89. <script>
  90. import { mapState } from 'vuex'
  91. import tabber from '@/components/base/tabbar.vue'
  92. import orderCard from '@/pages_order/center/orderCard.vue'
  93. export default {
  94. components: {
  95. orderCard,
  96. tabber,
  97. },
  98. data() {
  99. return {
  100. statistics: {},
  101. list1: [
  102. { id: '001', label: '我的收藏', icon: '/pages_order/static/center/icon-collect.png', path: '/pages_order/product/collectList' },
  103. { id: '004', label: '学员管理', icon: '/pages_order/static/center/icon-student.png', path: `/pages_order/member/memberList` },
  104. // todo
  105. { id: '003', label: '我的优惠券', icon: '/pages_order/static/center/icon-coupon.png', path: `/pages_order/common?key=instruc&title=服用说明` },
  106. ],
  107. list2: [
  108. // todo
  109. { id: '005', label: '我的评价', icon: '/pages_order/static/center/icon-comment.png', key: 'comment' },
  110. // todo: check key
  111. { id: '006', label: '关于我们', icon: '/pages_order/static/center/icon-msg.png', path: `/pages_order/common?key=aboutUs&title=关于我们` },
  112. { id: '007', label: '修改信息', icon: '/pages_order/static/center/icon-modifyInfo.png', path: `/pages_order/auth/wxUserInfo?mode=edit` },
  113. { id: '008', label: '退出登录', icon: '/pages_order/static/center/icon-logout.png', key: 'logout' },
  114. ],
  115. }
  116. },
  117. computed: {
  118. ...mapState(['userInfo', 'configList']),
  119. isLogin() {
  120. // todo: delete
  121. return true
  122. return this.userInfo && this.userInfo.id
  123. }
  124. },
  125. onShow() {
  126. if(uni.getStorageSync('token')){
  127. this.$store.commit('getUserInfo')
  128. this.fetchOrderStatistics()
  129. }
  130. },
  131. methods: {
  132. onClick(target) {
  133. const { key, path } = target
  134. switch(key) {
  135. case 'comment':
  136. this.$utils.navigateTo('/pages_order/comment/commentRecords')
  137. break
  138. case 'logout':
  139. this.$store.commit('logout')
  140. break
  141. default:
  142. path && this.$utils.navigateTo(path)
  143. break
  144. }
  145. },
  146. async fetchOrderStatistics() {
  147. return
  148. try {
  149. this.statistics = await this.$fetch('getOrderStatistics', { id: '' })
  150. } catch (err) {
  151. }
  152. },
  153. jumpToBindMember() {
  154. this.$utils.navigateTo('/pages_order/member/memberBind')
  155. },
  156. },
  157. }
  158. </script>
  159. <style scoped lang="scss">
  160. .page__view {
  161. width: 100vw;
  162. min-height: 100vh;
  163. background-color: $uni-bg-color;
  164. position: relative;
  165. /deep/ .nav-bar__view {
  166. position: fixed;
  167. top: 0;
  168. left: 0;
  169. }
  170. .nav-icon {
  171. width: 200rpx;
  172. height: auto;
  173. vertical-align: top;
  174. }
  175. }
  176. .bg {
  177. width: 100vw;
  178. height: auto;
  179. }
  180. .main {
  181. position: absolute;
  182. top: 176rpx;
  183. left: 0;
  184. width: 100%;
  185. }
  186. .content {
  187. width: 100%;
  188. padding: 16rpx 32rpx 80rpx 32rpx;
  189. box-sizing: border-box;
  190. }
  191. .user {
  192. column-gap: 24rpx;
  193. &-avatar {
  194. flex: none;
  195. width: 100rpx;
  196. height: 100rpx;
  197. border: 4rpx solid #FFFFFF;
  198. border-radius: 50%;
  199. overflow: hidden;
  200. &.is-default {
  201. width: 108rpx;
  202. height: 108rpx;
  203. border: none;
  204. }
  205. &-img {
  206. width: 100%;
  207. height: 100%;
  208. }
  209. }
  210. &-info {
  211. flex: 1;
  212. &-name {
  213. justify-content: flex-start;
  214. column-gap: 16rpx;
  215. font-family: PingFang SC;
  216. color: #FFFFFF;
  217. .highligt {
  218. font-weight: 600;
  219. font-size: 36rpx;
  220. line-height: 1.2;
  221. text-shadow: 0 1px 0 #37313140;
  222. }
  223. .light {
  224. font-size: 24rpx;
  225. }
  226. }
  227. &-desc {
  228. margin-top: 4rpx;
  229. font-family: PingFang SC;
  230. font-weight: 400;
  231. font-size: 24rpx;
  232. line-height: 1.8;
  233. color: #FFFFFF;
  234. text-shadow: 0 1px 0 #37313140;
  235. }
  236. &-tips {
  237. font-family: PingFang SC;
  238. font-weight: 400;
  239. font-size: 36rpx;
  240. line-height: 1.2;
  241. color: #FFFFFF;
  242. }
  243. }
  244. }
  245. .card {
  246. margin-top: 32rpx;
  247. width: 100%;
  248. background: #FFFFFF;
  249. border: 2rpx solid #FFFFFF;
  250. border-radius: 32rpx;
  251. box-sizing: border-box;
  252. .row {
  253. justify-content: space-between;
  254. width: 100%;
  255. padding: 40rpx;
  256. box-sizing: border-box;
  257. .label {
  258. font-family: PingFang SC;
  259. font-weight: 400;
  260. font-size: 28rpx;
  261. line-height: 1;
  262. color: #252545;
  263. .icon {
  264. margin-right: 16rpx;
  265. width: 40rpx;
  266. height: 40rpx;
  267. }
  268. }
  269. }
  270. }
  271. .btn-service {
  272. border: none;
  273. padding: 0;
  274. }
  275. .login {
  276. margin-top: 307rpx;
  277. padding: 0 128rpx;
  278. .btn {
  279. padding: 16rpx 0;
  280. font-family: PingFang SC;
  281. font-weight: 500;
  282. font-size: 36rpx;
  283. line-height: 1.4;
  284. color: #FFFFFF;
  285. background-image: linear-gradient(to right, #21FEEC, #019AF9);
  286. border-radius: 41rpx;
  287. }
  288. .tips {
  289. margin-top: 16rpx;
  290. text-align: center;
  291. font-family: PingFang SC;
  292. font-weight: 400;
  293. font-size: 26rpx;
  294. line-height: 1.4;
  295. color: #A3A3A3;
  296. }
  297. }
  298. .member-bind {
  299. justify-content: space-between;
  300. padding: 32rpx;
  301. background: linear-gradient(to right, #FBFEFF, #DAF3FF);
  302. .left {
  303. font-size: 36rpx;
  304. font-weight: 600;
  305. color: #252545;
  306. }
  307. .right {
  308. column-gap: 16rpx;
  309. .btn {
  310. padding: 6rpx 50rpx;
  311. font-size: 28rpx;
  312. font-weight: 500;
  313. line-height: 1.5;
  314. color: #FFFFFF;
  315. background: linear-gradient(to right, #21FEEC, #019AF9);
  316. border: 2rpx solid #00A9FF;
  317. border-radius: 30rpx;
  318. }
  319. }
  320. }
  321. </style>