member.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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. let _this = this;
  58. let platform = uni.getSystemInfoSync().platform;
  59. if(platform === 'ios'){
  60. uni.showModal({
  61. title: '提示',
  62. content: '由于相关规范,iOS功能暂不可用',
  63. success: function (res) {
  64. // res.confirm res.cancel
  65. }
  66. });
  67. return false
  68. }
  69. uni.showLoading({title: '数据处理中...'})
  70. this.$u.api.userBuy().then(data => {
  71. uni.hideLoading();
  72. uni.requestPayment({
  73. provider: 'wxpay',
  74. timeStamp: data.timeStamp,
  75. nonceStr: data.nonceStr,
  76. package: data.package,
  77. signType: data.signType,
  78. paySign: data.paySign,
  79. success: function (res) {
  80. console.log('success:' + JSON.stringify(res));
  81. //_this.$u.toast("支付成功")
  82. _this.queryOrder();
  83. },
  84. fail: function (err) {
  85. console.log('fail:' + JSON.stringify(err));
  86. //_this.$u.toast("支付失败")
  87. clearInterval(_this.interval)
  88. }
  89. });
  90. }).catch(res => {
  91. if(res.code === 10013){
  92. clearInterval(_this.interval)
  93. _this.getUser();
  94. }
  95. })
  96. },
  97. queryOrder(){
  98. let _this = this;
  99. _this.interval = setInterval(function () {
  100. _this.$u.api.userQuery().then(data => {
  101. if(data == 1){
  102. clearInterval(_this.interval)
  103. _this.getUser();
  104. }else if(data == 2){
  105. clearInterval(_this.interval)
  106. _this.$u.toast('支付失败');
  107. }
  108. })
  109. },1000)
  110. },
  111. getUser(){
  112. this.$u.api.userGet().then(data => {
  113. this.$u.vuex(this.$const.USER_DATA, data)
  114. })
  115. },
  116. },
  117. computed:{
  118. btnStyle() {
  119. return {
  120. border:'none',
  121. background:'linear-gradient(90deg, rgba(196,146,68,1) 0%, rgba(225,193,117,1) 100%, rgba(225,193,117,1) 100%)',
  122. width: '600rpx',
  123. padding: '42rpx 0',
  124. height: '100rpx',
  125. fontSize: '36rpx',
  126. fontWeight: 600
  127. };
  128. }
  129. },
  130. onReady(){
  131. this.getSetting();
  132. }
  133. }
  134. </script>
  135. <style lang="scss" scoped>
  136. .container {
  137. padding: 0;
  138. .header {
  139. .bg {
  140. position: absolute;
  141. background: url("@/static/images/member-bg.png") no-repeat center;
  142. background-size: 100% 100%;
  143. height: 300rpx;
  144. left: 0;
  145. top: 0;
  146. width: 750rpx;
  147. z-index: 0;
  148. }
  149. .title-group{
  150. position: relative;
  151. color: #CFBB8B;
  152. height: 220rpx;
  153. .title{
  154. font-size: 48rpx;
  155. font-weight: 600;
  156. }
  157. .sub-title{
  158. margin-top: 8rpx;
  159. font-size: 30rpx;
  160. }
  161. }
  162. }
  163. .main{
  164. position: relative;
  165. .bg{
  166. position: absolute;
  167. background: url("@/static/images/member-bg1.png") no-repeat center;
  168. background-size: 100% 100%;
  169. left: 50%;
  170. transform: translateX(-50%);
  171. height: 750rpx;
  172. width: 680rpx;
  173. z-index: 0;
  174. }
  175. .item-group{
  176. position: relative;
  177. height: 750rpx;
  178. padding: 32rpx 0;
  179. .title{
  180. font-size: 42rpx;
  181. font-weight: 600;
  182. color: #4e5958;
  183. }
  184. }
  185. .price{
  186. border: 4rpx solid #C49244;
  187. color: #c5923d;
  188. padding: 20rpx 60rpx;
  189. text-align: center;
  190. margin-bottom: 100rpx;
  191. margin-top: 100rpx;
  192. border-radius: 10rpx;
  193. .current{
  194. font-weight: 600;
  195. font-size: 42rpx;
  196. padding: 30rpx 0;
  197. }
  198. .origin{
  199. color: #e3c377;
  200. text-decoration: line-through;
  201. }
  202. .desc{
  203. font-size: 40rpx;
  204. padding: 30rpx 0;
  205. }
  206. }
  207. }
  208. }
  209. </style>