member.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <template>
  2. <app-layout>
  3. <view class="container">
  4. <view class="header">
  5. <view class="bg"></view>
  6. <view class="title-group dir-top-wrap cross-center main-center">
  7. <view class="title">桥架计算和公示表永久使用</view>
  8. <view class="sub-title">做桥架不求人,让你秒变大师</view>
  9. </view>
  10. </view>
  11. <view class="main">
  12. <view class="bg"></view>
  13. <view class="item-group dir-top-wrap cross-center">
  14. <view class="title">开通桥架会员</view>
  15. <view class="price">
  16. <view class="current">¥{{setting.member_price}}</view>
  17. <view class="origin">¥{{setting.origin_member_price}}</view>
  18. <view class="desc">永久使用</view>
  19. </view>
  20. <u-button shape="circle"
  21. type="success"
  22. hover-class="none"
  23. :custom-style="btnStyle"
  24. @click="handleBuy"
  25. v-if="vuex_user_data.is_vip == 0"
  26. >立即开通</u-button>
  27. <u-button shape="circle"
  28. type="success"
  29. hover-class="none"
  30. :custom-style="btnStyle"
  31. v-else
  32. >您已经是会员了</u-button>
  33. </view>
  34. </view>
  35. </view>
  36. </app-layout>
  37. </template>
  38. <script>
  39. import appLayout from "@/components/app-layout"
  40. export default {
  41. components:{
  42. appLayout,
  43. },
  44. data() {
  45. return {
  46. setting: {},
  47. interval: null
  48. }
  49. },
  50. methods: {
  51. getSetting(){
  52. this.$u.api.settingGet().then(data => {
  53. this.setting = data;
  54. })
  55. },
  56. handleBuy(){
  57. uni.showLoading({title: '数据处理中...'})
  58. let _this = this;
  59. this.$u.api.userBuy().then(data => {
  60. uni.hideLoading();
  61. uni.requestPayment({
  62. provider: 'wxpay',
  63. timeStamp: data.timeStamp,
  64. nonceStr: data.nonceStr,
  65. package: data.package,
  66. signType: data.signType,
  67. paySign: data.paySign,
  68. success: function (res) {
  69. console.log('success:' + JSON.stringify(res));
  70. //_this.$u.toast("支付成功")
  71. _this.queryOrder();
  72. },
  73. fail: function (err) {
  74. console.log('fail:' + JSON.stringify(err));
  75. //_this.$u.toast("支付失败")
  76. clearInterval(_this.interval)
  77. }
  78. });
  79. }).catch(res => {
  80. if(res.code === 10013){
  81. clearInterval(_this.interval)
  82. _this.getUser();
  83. }
  84. })
  85. },
  86. queryOrder(){
  87. let _this = this;
  88. _this.interval = setInterval(function () {
  89. _this.$u.api.userQuery().then(data => {
  90. if(data == 1){
  91. clearInterval(_this.interval)
  92. _this.getUser();
  93. }else if(data == 2){
  94. clearInterval(_this.interval)
  95. _this.$u.toast('支付失败');
  96. }
  97. })
  98. },1000)
  99. },
  100. getUser(){
  101. this.$u.api.userGet().then(data => {
  102. this.$u.vuex(this.$const.USER_DATA, data)
  103. })
  104. },
  105. },
  106. computed:{
  107. btnStyle() {
  108. return {
  109. border:'none',
  110. background:'linear-gradient(90deg, rgba(196,146,68,1) 0%, rgba(225,193,117,1) 100%, rgba(225,193,117,1) 100%)',
  111. width: '600rpx',
  112. padding: '42rpx 0',
  113. height: '100rpx',
  114. fontSize: '36rpx',
  115. fontWeight: 600
  116. };
  117. }
  118. },
  119. onReady(){
  120. this.getSetting();
  121. }
  122. }
  123. </script>
  124. <style lang="scss" scoped>
  125. .container {
  126. padding: 0;
  127. .header {
  128. .bg {
  129. position: absolute;
  130. background: url("@/static/images/member-bg.png") no-repeat center;
  131. background-size: 100% 100%;
  132. height: 300rpx;
  133. left: 0;
  134. top: 0;
  135. width: 750rpx;
  136. z-index: 0;
  137. }
  138. .title-group{
  139. position: relative;
  140. color: #CFBB8B;
  141. height: 220rpx;
  142. .title{
  143. font-size: 48rpx;
  144. font-weight: 600;
  145. }
  146. .sub-title{
  147. margin-top: 8rpx;
  148. font-size: 30rpx;
  149. }
  150. }
  151. }
  152. .main{
  153. position: relative;
  154. .bg{
  155. position: absolute;
  156. background: url("@/static/images/member-bg1.png") no-repeat center;
  157. background-size: 100% 100%;
  158. left: 50%;
  159. transform: translateX(-50%);
  160. height: 750rpx;
  161. width: 680rpx;
  162. z-index: 0;
  163. }
  164. .item-group{
  165. position: relative;
  166. height: 750rpx;
  167. padding: 32rpx 0;
  168. .title{
  169. font-size: 42rpx;
  170. font-weight: 600;
  171. color: #4e5958;
  172. }
  173. }
  174. .price{
  175. border: 4rpx solid #C49244;
  176. color: #c5923d;
  177. padding: 20rpx 60rpx;
  178. text-align: center;
  179. margin-bottom: 100rpx;
  180. margin-top: 100rpx;
  181. border-radius: 10rpx;
  182. .current{
  183. font-weight: 600;
  184. font-size: 42rpx;
  185. padding: 30rpx 0;
  186. }
  187. .origin{
  188. color: #e3c377;
  189. text-decoration: line-through;
  190. }
  191. .desc{
  192. font-size: 40rpx;
  193. padding: 30rpx 0;
  194. }
  195. }
  196. }
  197. }
  198. </style>