推拿小程序前端代码仓库
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.

388 lines
7.9 KiB

3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
  1. <!-- 会员中心页面 -->
  2. <template>
  3. <view class="page">
  4. <!-- 导航栏 -->
  5. <navbar title="会员中心" leftClick @leftClick="$utils.navigateBack" color="#fff" />
  6. <view class="content">
  7. <view class="flex user">
  8. <image class="user-avatar" :src="userInfo.headImage" mode="aspectFill"></image>
  9. <view class="user-info">
  10. <view class="flex user-name">
  11. <text>{{ userInfo.nickName }}</text>
  12. <template v-if="role === 'member-personal'">
  13. <image class="icon icon-role" src="@/static/image/center/icon-member-personal.png" mode="widthFix"></image>
  14. </template>
  15. <template v-else-if="role === 'member-business'">
  16. <image class="icon icon-role" src="@/static/image/center/icon-member-business.png" mode="widthFix"></image>
  17. </template>
  18. </view>
  19. <view class="user-desc">
  20. <template v-if="role">
  21. <!-- todo: 换回接口字段 -->
  22. <text>{{ `将于${'2026-12-12'} 到期` }}</text>
  23. </template>
  24. <template v-else>
  25. <text>暂未开通会员</text>
  26. </template>
  27. </view>
  28. </view>
  29. </view>
  30. <view class="consumption" v-if="!role">
  31. <!-- todo: 对接接口 -->
  32. <progress :current="1000" :total="3800"></progress>
  33. <text class="consumption-desc">{{ `累积消费达到${3800}元或直接充值即可成为会员` }}</text>
  34. </view>
  35. <view class="charge">
  36. <view class="charge-header">
  37. <view class="flex charge-header-title">充值会员</view>
  38. <view class="charge-header-mask"></view>
  39. </view>
  40. <view class="charge-content">
  41. <view class="flex charge-selection">
  42. <view class="flex charge-option"
  43. v-for="item in chargeOptions"
  44. :key="item.id"
  45. :class="[selectedChargeId === item.id ? 'is-active' : '']"
  46. @click="onSelectCharge(item.id)"
  47. >
  48. <view class="charge-option-value">
  49. <text class="charge-option-unit">¥</text>
  50. <text>{{ item.value }}</text>
  51. </view>
  52. </view>
  53. </view>
  54. <view class="charge-rights">
  55. <view class="flex charge-rights-header">
  56. <image class="title" src="../static/memberCenter/title-rights.png" mode="widthFix"></image>
  57. </view>
  58. <view class="charge-rights-content">
  59. <view class="charge-rights-item"
  60. v-for="(item, index) in rights"
  61. :key="item"
  62. >
  63. {{ `${index+1}${item}` }}
  64. </view>
  65. <image class="icon" src="../static/memberCenter/icon-rights.png" mode="widthFix"></image>
  66. </view>
  67. </view>
  68. </view>
  69. </view>
  70. </view>
  71. <view class="flex bar">
  72. <view class="flex count">
  73. <text>合计</text>
  74. <view class="price">
  75. <text class="price-unit">¥</text>
  76. <!-- todo: check -->
  77. <text>{{ totalPrice }}</text>
  78. </view>
  79. </view>
  80. <view class="btn btn-pay" @click="submit">
  81. 开通会员
  82. </view>
  83. </view>
  84. </view>
  85. </template>
  86. <script>
  87. import progress from '../components/progress.vue'
  88. import {
  89. mapState
  90. } from 'vuex'
  91. export default {
  92. name: "MemberCenter",
  93. components: {
  94. progress,
  95. },
  96. data() {
  97. return {
  98. role: 'member-business', // member-personal | member-business | merchant
  99. // todo: fetch
  100. chargeOptions: [
  101. {
  102. id: '001',
  103. value: 800,
  104. },
  105. {
  106. id: '002',
  107. value: 1800,
  108. },
  109. {
  110. id: '003',
  111. value: 2800,
  112. },
  113. ],
  114. selectedChargeId: '001',
  115. rights: [
  116. '会员享受专属折扣和优惠活动',
  117. '会员积分累积与抵扣功能',
  118. '成为会员后,得到平台发放的代金券',
  119. ]
  120. }
  121. },
  122. computed: {
  123. ...mapState(['userInfo']),
  124. selectedChargeObj() {
  125. return this.chargeOptions.find(item => item.id === this.selectedChargeId)
  126. },
  127. totalPrice() {
  128. return this.selectedChargeObj?.value || 0
  129. }
  130. },
  131. methods: {
  132. onSelectCharge(id) {
  133. // todo
  134. this.selectedChargeId = id
  135. },
  136. submit() {
  137. // todo: check jump to create order ?
  138. this.$api('recharge', res => {
  139. if(res.code == 200){
  140. uni.showToast({
  141. title: '充值成功',
  142. icon : 'none'
  143. })
  144. this.form.money = 0
  145. setTimeout(uni.navigateBack, 800, -1)
  146. }
  147. })
  148. }
  149. }
  150. }
  151. </script>
  152. <style scoped lang="scss">
  153. $bar-height: 132rpx;
  154. .page {
  155. padding-bottom: calc(#{$bar-height} + env(safe-area-inset-bottom));
  156. background-color: $uni-fg-color;
  157. min-height: 100vh;
  158. position: relative;
  159. /deep/ .nav-bar__view {
  160. padding-bottom: 413rpx;
  161. background-image: linear-gradient(#84A73F, #D8FF8F);
  162. }
  163. }
  164. .content {
  165. position: absolute;
  166. top: 175rpx;
  167. width: 100vw;
  168. z-index: 999;
  169. }
  170. .user {
  171. align-items: flex-start;
  172. color: $uni-text-color-inverse;
  173. font-size: 22rpx;
  174. margin: 0 18rpx;
  175. &-avatar {
  176. width: 147rpx;
  177. height: 147rpx;
  178. margin-right: 8rpx;
  179. }
  180. &-info {
  181. flex: 1;
  182. }
  183. &-name {
  184. font-size: 32rpx;
  185. margin-top: 16rpx;
  186. justify-content: flex-start;
  187. .icon {
  188. height: auto;
  189. &-role {
  190. width: 138rpx;
  191. }
  192. }
  193. }
  194. &-desc {
  195. margin-top: 26rpx;
  196. }
  197. }
  198. .consumption {
  199. margin: 0 28rpx;
  200. &-desc {
  201. color: $uni-text-color-inverse;
  202. font-size: 22rpx;
  203. margin-top: 1rpx;
  204. }
  205. }
  206. .charge {
  207. background-color: $uni-fg-color;
  208. border-top-left-radius: 18rpx;
  209. border-top-right-radius: 18rpx;
  210. margin-top: 45rpx;
  211. &-header {
  212. $header-height: 90rpx;
  213. height: $header-height;
  214. position: relative;
  215. &-title {
  216. width: calc(50% + 25rpx);
  217. height: 100%;
  218. color: $uni-text-color-inverse;
  219. font-size: 28rpx;
  220. background-image: linear-gradient(#84A73F, #D8FF8F);
  221. box-sizing: border-box;
  222. border-top-left-radius: 18rpx;
  223. border-bottom-right-radius: 90rpx;
  224. }
  225. &-mask {
  226. $marsk-width: 50rpx;
  227. position: absolute;
  228. top: 0;
  229. right: 50%;
  230. transform: translateX(25rpx);
  231. // height: 100%;
  232. // width: 70rpx;
  233. width: 0;
  234. height: 0;
  235. border-top: calc(#{$header-height}/2) solid transparent;
  236. border-left: calc(#{$marsk-width}/2) solid transparent;
  237. border-bottom: calc(#{$header-height}/2) solid $uni-fg-color;
  238. border-right: calc(#{$marsk-width}/2) solid $uni-fg-color;
  239. }
  240. }
  241. &-content {
  242. padding: 57rpx 14rpx;
  243. }
  244. &-selection {
  245. justify-content: space-between;
  246. font-size: 0;
  247. }
  248. &-option {
  249. width: 230rpx;
  250. height: 248rpx;
  251. box-sizing: border-box;
  252. background-color: #F5F5F5;
  253. border: 3rpx solid #C7C7C7;
  254. border-radius: 16rpx;
  255. box-shadow: 0rpx 3rpx 6rpx 0rpx #eef3e3;
  256. color: #999999;
  257. &-value {
  258. font-size: 61rpx;
  259. }
  260. &-unit {
  261. font-size: 34rpx;
  262. margin-right: 6rpx;
  263. }
  264. &.is-active {
  265. background-color: rgba($color: #E9FFC3, $alpha: 0.74);
  266. border-color: $uni-color-light;
  267. color: #F64041;
  268. }
  269. }
  270. &-rights {
  271. margin-top: 67rpx;
  272. &-header {
  273. .title {
  274. width: 202rpx;
  275. height: auto;
  276. }
  277. }
  278. &-content {
  279. margin-top: 31rpx;
  280. background-color: rgba($color: #E2FFAE, $alpha: 0.71);
  281. border-radius: 16rpx;
  282. padding: 29rpx 30rpx;
  283. width: 100%;
  284. min-height: 500rpx;
  285. box-sizing: border-box;
  286. position: relative;
  287. .icon {
  288. position: absolute;
  289. top: 23rpx;
  290. right: 11rpx;
  291. width: 131rpx;
  292. height: auto;
  293. }
  294. }
  295. &-item {
  296. margin-top: 26rpx;
  297. color: $uni-color-light;
  298. font-size: 28rpx;
  299. }
  300. }
  301. }
  302. // 下单
  303. .bar {
  304. position: fixed;
  305. z-index: 1000;
  306. bottom: 0;
  307. left: 0;
  308. width: 100vw;
  309. height: $bar-height;
  310. padding-bottom: env(safe-area-inset-bottom);
  311. background-color: $uni-fg-color;
  312. .count {
  313. flex: 1;
  314. color: #000000;
  315. font-size: 28rpx;
  316. margin-left: 48rpx;
  317. justify-content: flex-start;
  318. .price {
  319. color: #FF2A2A;
  320. font-size: 30rpx;
  321. &-unit {
  322. font-size: 18rpx;
  323. }
  324. }
  325. }
  326. .btn {
  327. border: none;
  328. line-height: 1;
  329. background-color: transparent;
  330. padding: 0;
  331. width: auto;
  332. height: auto;
  333. margin: 0;
  334. &-pay {
  335. margin-right: 41rpx;
  336. padding: 24rpx 137rpx;
  337. color: $uni-text-color-inverse;
  338. font-size: 28rpx;
  339. border-radius: 44rpx;
  340. background-image: linear-gradient(to right, #84A73F, #D8FF8F);
  341. }
  342. }
  343. }
  344. </style>