index.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. <template>
  2. <view>
  3. <view class="">
  4. <view class="margin-lr margin-top" style="position: relative;border-radius: 10upx;overflow: hidden;">
  5. <image src="../static/vip.png" style="width: 100%;height: 250rpx;"></image>
  6. <view class=" u-flex u-p-l-30 u-p-t-80 u-p-b-30" style="position: absolute;top: 0;width: 100%;">
  7. <view class="u-m-r-20">
  8. <u-avatar :src="avatar" size="100"></u-avatar>
  9. </view>
  10. <view class="u-flex-1 ">
  11. <view class="u-font-18 text-white text-bold" style="color: #C59D7C;">{{userName}}</view>
  12. <view class="u-font-14 u-m-t-10 u-tips-color" style="color: #C59D7C;" v-if="!isVip">您目前还未开通会员</view>
  13. <view class="u-font-14 u-m-t-10 u-tips-color" style="color: #C59D7C;" v-if="isVip&&vipEndTime">会员到期:{{vipEndTime}}</view>
  14. </view>
  15. </view>
  16. </view>
  17. <view class="flex margin-top-sm flex-wrap padding-lr-sm">
  18. <view v-for="(item,index) in vipList" :key='index' @click="select(item)" class=""
  19. style="display: inline-block;width: 216rpx;height: 200rpx;margin: 10rpx 10rpx 0rpx;">
  20. <view class="text-center flex flex-direction justify-center padding-tb radius"
  21. :class="selNum == item.id?'active': ''"
  22. style="color: #DFC5A7;width: 216rpx;height: 200rpx;background: linear-gradient(-30deg, #2B2A30, #4A4A4A);border: 1px;">
  23. <view class="text-bold">{{item.vipName}}</view>
  24. <view class="text-bold" style="margin-top: 20upx;">¥<text class="text-xxl">{{item.money}}</text></view>
  25. <!-- <view>立即预约</view> -->
  26. </view>
  27. </view>
  28. </view>
  29. <view class="padding-tb radius margin-top margin-lr"
  30. style="background-color: #343339;border-radius: 10upx;padding-bottom: 60rpx;">
  31. <view class="text-center text-xl text-bold " style="color: #CAB49C;">开通专享特权</view>
  32. <view class="flex flex-wrap">
  33. <view v-for="(item,index) in MemberList" :key="index"
  34. style="width: 33%;text-align: center;margin-top: 34upx;">
  35. <image :src="item.memberImg" mode="" style="margin: 0 auto;height: 45rpx;width: 45rpx;"></image>
  36. <view class="grid-text margin-top-sm" style="color: #DFC5A7;">{{item.memberName}}</view>
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. <view style="height: 110rpx;"></view>
  42. <view class="flex justify-between cu-bar foot bg padding-lr" style="padding-top: 20rpx;padding-bottom: 20rpx;" v-if="!isVip">
  43. <view style="color: #DFC5A7;">
  44. 实付:<text style="font-size: 38upx;margin-top: 8upx;">{{price}}</text>元
  45. </view>
  46. <view class="">
  47. <u-button :custom-style="customStyle" @click="pay()" shape="circle" :hair-line="false">立即开通</u-button>
  48. </view>
  49. </view>
  50. </view>
  51. </template>
  52. <script>
  53. export default {
  54. data() {
  55. return {
  56. customStyle: {
  57. width: '250rpx',
  58. color: '#402321',
  59. background: "#DFC5A7",
  60. border: 0,
  61. fontWeight: '700'
  62. },
  63. gridData: [{
  64. title: '专享九折',
  65. image: '../static/1.png'
  66. },
  67. // {
  68. // title: '特权礼物',
  69. // image: '../static/2.png'
  70. // },
  71. {
  72. title: '身份标识',
  73. image: '../static/3.png'
  74. },
  75. // {
  76. // title: '超值专享券',
  77. // image: '../static/4.png'
  78. // },
  79. // {
  80. // title: '商家特权',
  81. // image: '../static/5.png'
  82. // },
  83. // {
  84. // title: '定制挂件',
  85. // image: '../static/6.png'
  86. // }
  87. ],
  88. avatar: '',
  89. userName: '匿名',
  90. vipList: [],
  91. selNum: 2,
  92. newPrice: 0,
  93. money: 0,
  94. price: 0,
  95. MemberList: [],
  96. isVip: false,
  97. vipEndTime:''
  98. }
  99. },
  100. onLoad() {
  101. this.avatar = uni.getStorageSync('avatar')
  102. this.userName = uni.getStorageSync('userName')
  103. // this.getVipList()
  104. // this.getMemberList()
  105. // this.getMoney()
  106. // this.getIsVip()
  107. // this.getUserInfo()
  108. },
  109. methods: {
  110. getUserInfo() {
  111. this.$Request.get("/app/user/selectUserById").then(res => {
  112. if (res.code == 0) {
  113. this.avatar = res.data.avatar?res.data.avatar: '../../static/logo.png'
  114. this.vipEndTime = res.data.vipEndTime
  115. uni.setStorageSync('avatar', res.data.avatar)
  116. }
  117. });
  118. },
  119. //获取VIP列表
  120. getVipList() {
  121. this.$Request.get('/app/VipDetails/selectVipDetails').then(res => {
  122. if (res.code == 0) {
  123. this.vipList = res.data
  124. this.price = this.vipList[0].money
  125. }
  126. })
  127. },
  128. // 获取特权列表
  129. getMemberList() {
  130. this.$Request.get('/app/member/selectMemberList').then(res => {
  131. if (res.code == 0) {
  132. this.MemberList = res.data
  133. }
  134. })
  135. },
  136. getIsVip() {
  137. this.$Request.get("/app/UserVip/isUserVip").then(res => {
  138. if (res.code == 0) {
  139. this.isVip = res.data
  140. }
  141. });
  142. },
  143. // 我的金元
  144. getMoney() {
  145. this.$Request.get("/app/userMoney/selectMyMoney").then(res => {
  146. if (res.code == 0 && res.data) {
  147. this.money = res.data.money
  148. }
  149. });
  150. },
  151. select(e) {
  152. this.selNum = e.id
  153. this.price = e.money
  154. },
  155. pay() {
  156. console.log(this.money, this.newPrice)
  157. if (this.money >= this.price) {
  158. let data = {
  159. id: this.selNum,
  160. type: '2'
  161. }
  162. this.$Request.get('/app/orders/generateOrder', data).then(res => {
  163. if (res.code == 0) {
  164. this.$Request.get('/app/userMoney/payTakingOrder', {
  165. orderId: res.data.ordersId
  166. }).then(res => {
  167. console.log(res.data)
  168. if (res.code == 0) {
  169. this.isVip = true
  170. uni.showToast({
  171. title: '开通成功!'
  172. })
  173. setTimeout(function() {
  174. uni.navigateBack()
  175. },1000)
  176. } else {
  177. uni.showToast({
  178. title: res.msg
  179. })
  180. }
  181. })
  182. }
  183. })
  184. } else {
  185. uni.showModal({
  186. title: '提示',
  187. content: '当前账户余额不足,请充值',
  188. success: function(res) {
  189. if (res.confirm) {
  190. console.log('用户点击确定');
  191. uni.navigateTo({
  192. url: '/my/wallet/index'
  193. })
  194. } else if (res.cancel) {
  195. console.log('用户点击取消');
  196. }
  197. }
  198. })
  199. }
  200. }
  201. },
  202. computed: {
  203. }
  204. }
  205. </script>
  206. <style>
  207. .bg {
  208. background-color: #343339;
  209. }
  210. .btn {
  211. width: 100%;
  212. height: 88upx;
  213. background: linear-gradient(0deg, #af8262 0%, #cab49c 100%);
  214. border-radius: 44upx;
  215. text-align: center;
  216. line-height: 88upx;
  217. margin-top: 40upx;
  218. font-size: 34upx;
  219. font-weight: 600;
  220. color: #402321;
  221. }
  222. .active {
  223. border: 1px solid #cab49c !important;
  224. border-radius: ;
  225. background: black !important;
  226. }
  227. </style>