member_recharge.html 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. {extend name="public/container"}
  2. {block name="title"}会员充值{/block}
  3. {block name="content"}
  4. <div v-cloak id="app" class="member-recharge">
  5. <div class="user">
  6. <img :src="userInfo.avatar">
  7. <div class="name" v-html="userInfo.nickname"> </div>
  8. <div class="time" v-if="userInfo.level>0 && userInfo.surplus>0 && userInfo.is_permanent==0">
  9. <span class="iconfont iconshijian1"></span>您的会员还剩{{userInfo.surplus}}天
  10. </div>
  11. <div class="time" v-else-if="userInfo.level>0 && userInfo.is_permanent==1">
  12. <span class="iconfont iconshijian1"></span>您是永久会员
  13. </div>
  14. <div class="time" v-else>
  15. <span class="iconfont iconshijian1"></span>您还不是会员
  16. </div>
  17. </div>
  18. <!-- 会员期限选择 -->
  19. <div class="limit">
  20. <div class="titles">会员期限选择</div>
  21. <ul>
  22. <li v-for="(item, index) in membershipList" :key="index">
  23. <div class="text">
  24. <div class="price">
  25. ¥ <span class="number">{{item.price}}</span><span v-if="item.sale>0">优惠¥{{item.sale}}</span>
  26. </div>
  27. <div class="info">{{item.title}}会员¥{{item.original_price}}</div>
  28. </div>
  29. <button class="btn" @click="purchase(item)">购买</button>
  30. </li>
  31. </ul>
  32. <div class="service" v-if="servicePhone">
  33. <span class="iconfont iconkefu"></span>
  34. 联系客服
  35. <a :href="`tel:${servicePhone}`">{{servicePhone}}</a>
  36. </div>
  37. <payment @change="changeVal" :payment="payment" :money="money" :isyue="is_yue" :special_id="id" :isAlipay="is_alipay" :iswechat="isWechat" :pay_type_num="pay_type_num" ></payment>
  38. <enter :appear="appear" @change="changeVal" :url="url" :site_name="site_name"></enter>
  39. <shortcut></shortcut>
  40. </div>
  41. </div>
  42. {/block}
  43. {block name='foot'}
  44. <script>
  45. var site_name = '{$Auth_site_name}';
  46. var servicePhone = '{$servicePhone}',isWechat={$isWechat ? 'true' : 'false'},is_yue=false,is_alipay={$is_alipay ? 'true' : 'false'};
  47. require(['vue', 'helper', 'store','{__WAP_PATH}zsff/js/payment.js', '{__WAP_PATH}zsff/js/enter.js', '{__WAP_PATH}zsff/js/shortcut.js'], function (Vue, $h, app) {
  48. new Vue({
  49. el: '#app',
  50. data: {
  51. vipType: [],
  52. servicePhone: servicePhone,
  53. appear: true,
  54. site_name: site_name,
  55. userInfo:{},
  56. membershipList:[],
  57. orderId:'',
  58. payment:true,
  59. id:0,
  60. money:0,
  61. isWechat:isWechat,
  62. pay_type_num:10,
  63. is_alipay: is_alipay, //支付宝是否开启
  64. is_yue:is_yue, //余额是否开启
  65. url:isWechat ? $h.U({c:'index',a:'login'}):$h.U({c:'login',a:'phone_check'})
  66. },
  67. mounted: function () {
  68. this.userinfo();
  69. this.getMembershipList();
  70. },
  71. methods: {
  72. userinfo:function(){
  73. var that=this;
  74. app.baseGet($h.U({ c: 'auth_api', a: 'userInfo' }), function (res) {
  75. that.userInfo=res.data.data;
  76. });
  77. },
  78. getMembershipList:function(){
  79. var that=this;
  80. app.baseGet($h.U({ c: 'auth_api', a: 'membershipLists' }), function (res) {
  81. that.membershipList=res.data.data;
  82. });
  83. },
  84. purchase:function(item){
  85. var that=this;
  86. app.baseGet($h.U({c:'index',a:'user_login'}),function (res) {
  87. that.appear=true;
  88. that.id=item.id;
  89. that.money=item.price;
  90. that.payment=false;
  91. }.bind(this),function (res) {
  92. that.appear=false;
  93. return false;
  94. }.bind(this));
  95. },
  96. pay_order:function(data){
  97. this.orderId=data.result.orderId || '';
  98. switch (data.status){
  99. case "PAY_ERROR":case 'ORDER_EXIST':case 'ORDER_ERROR':
  100. this.extendOrder(data.msg);
  101. break;
  102. case 'WECHAT_PAY':
  103. this.wechatPay(data.result.jsConfig);
  104. break;
  105. case 'SUCCESS':
  106. this.successOrder(data.msg);
  107. break;
  108. case 'ZHIFUBAO_PAY':
  109. window.location.href=$h.U({c:'Alipay',a:'index',q:{info:data.result,params:'member'}});
  110. break;
  111. }
  112. },
  113. wechatPay:function(config){
  114. var that = this;
  115. mapleWx($jssdk(),function(){
  116. this.chooseWXPay(config,function(){
  117. that.successOrder();
  118. },{
  119. fail:that.extendOrder,
  120. cancel:that.extendOrder
  121. });
  122. });
  123. },
  124. successOrder:function(msg){
  125. $h.showMsg({
  126. title:msg ? msg :'支付成功',
  127. icon:'success',
  128. success:function (){
  129. window.location.href=$h.U({c:'special',a:'member_manage'});
  130. }
  131. });
  132. },
  133. extendOrder:function(msg){
  134. var msg = msg ? msg : '支付失败';
  135. $h.showMsg({
  136. title: typeof msg == 'object' ? '支付失败' : msg,
  137. success: function () {
  138. location.reload();
  139. }
  140. })
  141. },
  142. enter: function () {
  143. this.appear = false;
  144. },
  145. //关闭登录
  146. loginClose:function(value){
  147. this.appear=value;
  148. },
  149. //登录完成回调事件
  150. logComplete:function(){
  151. this.appear=true;
  152. },
  153. //关闭支付
  154. payClose:function(value){
  155. this.payment=value;
  156. },
  157. //所有插件回调处理事件
  158. changeVal: function (opt) {
  159. if (typeof opt != 'object') opt = {};
  160. var action = opt.action || '';
  161. var value = opt.value || '';
  162. this[action] && this[action](value);
  163. },
  164. }
  165. });
  166. });
  167. </script>
  168. {/block}