index1.vue 6.1 KB

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