member.vue 6.4 KB

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