member.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  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. <u-popup v-model="modal.show" mode="bottom" :mask-close-able="false" border-radius="15">
  37. <view class="popup-content">
  38. <view class="title">需要绑定您的手机号</view>
  39. <view class="btn-popup main-between">
  40. <button class="btn main-center cross-center" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">获取手机号</button>
  41. </view>
  42. </view>
  43. </u-popup>
  44. </app-layout>
  45. </template>
  46. <script>
  47. import appLayout from "@/components/app-layout"
  48. export default {
  49. components:{
  50. appLayout,
  51. },
  52. data() {
  53. return {
  54. setting: {},
  55. interval: null,
  56. modal: {
  57. show: false
  58. },
  59. }
  60. },
  61. methods: {
  62. getSetting(){
  63. this.$u.api.settingGet().then(data => {
  64. this.setting = data;
  65. })
  66. },
  67. handleBuy(){
  68. let _this = this;
  69. /*if(this.$platform === 'ios'){
  70. uni.showModal({
  71. title: '提示',
  72. content: '由于相关规范,iOS功能暂不可用',
  73. success: function (res) {
  74. // res.confirm res.cancel
  75. }
  76. });
  77. return false
  78. }*/
  79. if(!this.vuex_user_data.phone_num){
  80. this.modal.show = true;
  81. return;
  82. }
  83. uni.showLoading({title: '数据处理中...'})
  84. this.$u.api.userBuy().then(data => {
  85. uni.hideLoading();
  86. uni.requestPayment({
  87. provider: 'wxpay',
  88. timeStamp: data.timeStamp,
  89. nonceStr: data.nonceStr,
  90. package: data.package,
  91. signType: data.signType,
  92. paySign: data.paySign,
  93. success: function (res) {
  94. console.log('success:' + JSON.stringify(res));
  95. //_this.$u.toast("支付成功")
  96. _this.queryOrder();
  97. },
  98. fail: function (err) {
  99. console.log('fail:' + JSON.stringify(err));
  100. //_this.$u.toast("支付失败")
  101. clearInterval(_this.interval)
  102. }
  103. });
  104. }).catch(res => {
  105. if(res.code === 10013){
  106. clearInterval(_this.interval)
  107. _this.getUser();
  108. }
  109. })
  110. },
  111. queryOrder(){
  112. let _this = this;
  113. _this.interval = setInterval(function () {
  114. _this.$u.api.userQuery().then(data => {
  115. if(data == 1){
  116. clearInterval(_this.interval)
  117. _this.getUser();
  118. }else if(data == 2){
  119. clearInterval(_this.interval)
  120. _this.$u.toast('支付失败');
  121. }
  122. })
  123. },1000)
  124. },
  125. getUser(){
  126. this.$u.api.userGet().then(data => {
  127. this.$u.vuex(this.$const.USER_DATA, data)
  128. })
  129. },
  130. getPhoneNumber(phoneNumber){
  131. if(phoneNumber.detail.errMsg !== 'getPhoneNumber:ok'){
  132. this.$u.toast('已取消');
  133. return
  134. }
  135. uni.checkSession({
  136. success: data => {
  137. this.$u.api.userBindPhone(phoneNumber.detail).then(data => {
  138. this.$u.vuex(this.$const.USER_DATA,data)
  139. this.modal.show = false
  140. this.handleBuy();
  141. })
  142. },
  143. fail: err => {
  144. this.sureClearCache()
  145. }
  146. })
  147. },
  148. sureClearCache(){
  149. this.$u.vuex(this.$const.USER_TOKEN,null)
  150. this.$u.vuex(this.$const.USER_DATA,null)
  151. this.$jump({url:'/pages/login/login?redirect=pages/my/index',type:'redirect'})
  152. },
  153. },
  154. computed:{
  155. btnStyle() {
  156. return {
  157. border:'none',
  158. background:'linear-gradient(90deg, rgba(196,146,68,1) 0%, rgba(225,193,117,1) 100%, rgba(225,193,117,1) 100%)',
  159. width: '600rpx',
  160. padding: '42rpx 0',
  161. height: '100rpx',
  162. fontSize: '36rpx',
  163. fontWeight: 600
  164. };
  165. }
  166. },
  167. onReady(){
  168. this.getSetting();
  169. }
  170. }
  171. </script>
  172. <style lang="scss" scoped>
  173. .container {
  174. padding: 0;
  175. .header {
  176. .bg {
  177. position: absolute;
  178. background: url("@/static/images/member-bg.png") no-repeat center;
  179. background-size: 100% 100%;
  180. height: 300rpx;
  181. left: 0;
  182. top: 0;
  183. width: 750rpx;
  184. z-index: 0;
  185. }
  186. .title-group{
  187. position: relative;
  188. color: #CFBB8B;
  189. height: 220rpx;
  190. .title{
  191. font-size: 48rpx;
  192. font-weight: 600;
  193. }
  194. .sub-title{
  195. margin-top: 8rpx;
  196. font-size: 30rpx;
  197. }
  198. }
  199. }
  200. .main{
  201. position: relative;
  202. .bg{
  203. position: absolute;
  204. background: url("@/static/images/member-bg1.png") no-repeat center;
  205. background-size: 100% 100%;
  206. left: 50%;
  207. transform: translateX(-50%);
  208. height: 750rpx;
  209. width: 680rpx;
  210. z-index: 0;
  211. }
  212. .item-group{
  213. position: relative;
  214. height: 750rpx;
  215. padding: 32rpx 0;
  216. .title{
  217. font-size: 42rpx;
  218. font-weight: 600;
  219. color: #4e5958;
  220. }
  221. }
  222. .price{
  223. border: 4rpx solid #C49244;
  224. color: #c5923d;
  225. padding: 20rpx 60rpx;
  226. text-align: center;
  227. margin-bottom: 100rpx;
  228. margin-top: 100rpx;
  229. border-radius: 10rpx;
  230. .current{
  231. font-weight: 600;
  232. font-size: 42rpx;
  233. padding: 30rpx 0;
  234. }
  235. .origin{
  236. color: #e3c377;
  237. text-decoration: line-through;
  238. }
  239. .desc{
  240. font-size: 40rpx;
  241. padding: 30rpx 0;
  242. }
  243. }
  244. }
  245. }
  246. .popup-content{
  247. height: 280rpx;
  248. position: relative;
  249. .title{
  250. padding: 20rpx 30rpx;
  251. font-weight: 600;
  252. font-size: 42rpx;
  253. }
  254. .btn-popup{
  255. position: absolute;
  256. bottom: 0;
  257. width: 100%;
  258. }
  259. .btn{
  260. background: $main-color;
  261. color: #fff;
  262. border-radius: 0;
  263. font-size: 28rpx;
  264. height: 100rpx;
  265. flex: 1;
  266. &.cancel{
  267. background: #f5f5f5;
  268. color: #666;
  269. }
  270. &:after{
  271. content: unset;
  272. }
  273. }
  274. }
  275. </style>