joinvip.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. <template>
  2. <view class="page">
  3. <ul class="profile" v-if="user.vip>0" >
  4. <li>VIP类型:</li>
  5. <li>
  6. <block v-if="user.vip==3">团队VIP</block>
  7. <block v-else>个人VIP</block>
  8. </li>
  9. </ul>
  10. <ul class="profile" v-if="user.vip>0" >
  11. <li>当前VIP:</li>
  12. <li>
  13. <span style="color:#666"> {{timestampToTime(user.vip_time)}}</span> 到期
  14. </li>
  15. </ul>
  16. <block v-if="user.isdaili==1 && user.vip<=1">
  17. <ul class="profile">
  18. <li>购买类型:</li>
  19. <li>
  20. <radio :checked="type==0" @tap="change_tab(0)">
  21. <block v-if="user.vip>0">续费</block><block v-else>个人</block>VIP
  22. </radio>
  23. <radio :checked="type==1" @tap="change_tab(1)" style="margin-left: 20px;">
  24. <block v-if="user.vip>0">升级为团队</block><block v-else>团队</block>VIP
  25. </radio>
  26. </li>
  27. </ul>
  28. </block>
  29. <ul class="profile" >
  30. <li>购买时长:</li>
  31. <li>
  32. <view :class="{'money':true,'active':buytime==1}" @tap="set_time(1)">一月</view>
  33. <view :class="{'money':true,'active':buytime==12}" @tap="set_time(12)">一年</view>
  34. </li>
  35. </ul>
  36. <ul class="profile" >
  37. <li>需要支付:</li>
  38. <li>
  39. <view style="color: #FF2600;font-size: 16px;font-weight: 600;">
  40. {{money}}
  41. </view>
  42. </li>
  43. </ul>
  44. <view style="margin:15px auto;display:block;width: 80%;">
  45. <button class="button1" @tap="click_pay()">确认支付</button>
  46. </view>
  47. <view style="margin-top:30px auto;display:block;width: 100%;text-align: center;color: #666;">
  48. 注:开通团队版vip可免费给<span style='color: #2319DC;'>{{system.vip1_max}}</span>个下级开通个人版vip
  49. </view>
  50. <view @tap="vipinfo" style="margin:15px auto;display:block;width: 80%;text-align: center;color: #2319DC;text-decoration: underline;">
  51. 查看VIP特权介绍
  52. </view>
  53. <payment v-if="showpay" :getmoney="money" title="确认支付" type="vip" :payinfo="payinfo" :fix="fix" @close="showpay=false;" @payresult="payresult"></payment>
  54. <iospay v-if="submit_iospay" type="vip" :money_select="money_select" :money="money" @cancel_pay="submit_iospay=false;"></iospay>
  55. </view>
  56. </template>
  57. <script>
  58. import payment from '../../components/payment.vue'
  59. import iospay from "../../components/iospay.vue"
  60. export default {
  61. components:{
  62. payment,
  63. iospay
  64. },
  65. computed:{
  66. },
  67. data() {
  68. return {
  69. system:uni.getStorageSync('system'),
  70. user:uni.getStorageSync('userInfo'),
  71. buytime:12,
  72. showpay:false,
  73. payinfo:{},
  74. fix:true,
  75. type:0,
  76. money:0,
  77. money_select:0,
  78. is_iospay:false,
  79. submit_iospay:false,
  80. };
  81. },
  82. methods:{
  83. set_time(num){
  84. this.buytime=num;
  85. var vip=this.user.vip;
  86. var type=this.type;
  87. var buytime=this.buytime;
  88. var money=0;
  89. if(vip==0){
  90. if(type==0){
  91. if(buytime==1)
  92. {
  93. money=this.system.vip_month;
  94. }else{
  95. money=this.system.vip_year;
  96. }
  97. }else{
  98. if(buytime==1)
  99. {
  100. money=this.system.vip1_month;
  101. }else{
  102. money=this.system.vip1_year
  103. }
  104. }
  105. }
  106. else if(vip==1){
  107. if(type==0){
  108. if(buytime==1)
  109. {
  110. money=this.system.vip_month;
  111. }else{
  112. money=this.system.vip_year;
  113. }
  114. }else{
  115. var lasttime=this.user.vip_lasttime;
  116. if(lasttime>30){
  117. var lastmoney=parseInt(lasttime*this.system.vip_year/365);
  118. }
  119. else {
  120. var lastmoney=parseInt(lasttime*this.system.vip_month/30);
  121. }
  122. if(lastmoney>this.system.vip_month && buytime==1){
  123. buytime=12;
  124. this.buytime=12;
  125. }
  126. if(buytime==1)
  127. {
  128. money=parseInt(this.system.vip1_month-lastmoney);
  129. }else{
  130. money=parseInt(this.system.vip1_year-lastmoney);
  131. }
  132. }
  133. }
  134. else{
  135. if(buytime==1)
  136. {
  137. money=this.system.vip1_month;
  138. }else{
  139. money=this.system.vip1_year
  140. }
  141. }
  142. // #ifdef APP-PLUS
  143. if(plus.os.name=='iOS' && this.system.iosvip==1) {
  144. if(type==0){
  145. if(buytime==1)
  146. {
  147. money=this.system.vip_month;
  148. }else{
  149. money=this.system.vip_year;
  150. }
  151. }else{
  152. if(buytime==1)
  153. {
  154. money=this.system.vip1_month;
  155. }else{
  156. money=this.system.vip1_year
  157. }
  158. }
  159. }
  160. //#endif
  161. this.money= money;
  162. if(type==0){
  163. if(buytime==1) this.money_select=0;
  164. else this.money_select=1;
  165. }else{
  166. if(buytime==1) this.money_select=2;
  167. else this.money_select=3;
  168. }
  169. },
  170. change_tab(num) {
  171. this.type=num;
  172. this.set_time(this.buytime);
  173. },
  174. vipinfo(){
  175. uni.navigateTo({
  176. url:'vipinfo'
  177. })
  178. },
  179. click_pay(){
  180. // #ifdef APP-PLUS
  181. if( plus.os.name=='iOS' && this.system.iosvip==1) {
  182. this.is_iospay=true;
  183. this.submit_iospay=true;
  184. return false;
  185. }
  186. // #endif
  187. if(parseFloat(this.money)>parseFloat(this.user.money1)){
  188. uni.showModal({
  189. title: '可用余额不足',
  190. content: "您的可用余额不足,请先去充值!",
  191. showCancel: true,
  192. cancelText: '取消',
  193. confirmText: '去充值',
  194. success: res => {
  195. if(res.confirm) {
  196. uni.redirectTo({
  197. url:"/pages/mine/recharge"
  198. })
  199. }
  200. }
  201. });
  202. return false;
  203. }
  204. this.showpay=true;
  205. this.payinfo={time:this.buytime,userid:this.user.id,money:this.money,viptype:this.type}
  206. },
  207. payresult(e){
  208. uni.navigateBack();
  209. // uni.reLaunch({
  210. // url:'index'
  211. // })
  212. },
  213. timestampToTime(timestamp) {
  214. var date = new Date(timestamp * 1000);//时间戳为10位需*1000,时间戳为13位的话不需乘1000
  215. var Y = date.getFullYear() ;
  216. var M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1);
  217. var D = date.getDate();
  218. var h = date.getHours();
  219. var m = date.getMinutes();
  220. var s = date.getSeconds();
  221. if(D<10) D='0'+D;
  222. if(h<10) h='0'+h;
  223. if(m<10) m='0'+m;
  224. if(s<10) s='0'+s;
  225. return Y+'年'+M+'月'+D+'日';
  226. }
  227. },
  228. onLoad(opts) {
  229. if(this.user.vip>0){
  230. uni.setNavigationBarTitle({
  231. title:'VIP续费'
  232. })
  233. }
  234. if(opts.type==1 && this.user.vip<3) this.change_tab(1);
  235. if(this.user.vip==3) this.type=1;
  236. this.set_time(12);
  237. }
  238. }
  239. </script>
  240. <style lang="scss" scoped>
  241. @import "@/static/css/user.css";
  242. .page{
  243. background-color: #fafafa;
  244. }
  245. .profile,.login-lines1{
  246. background-color: #fff;
  247. margin: 10px auto;
  248. width: 100%;
  249. vertical-align: middle;
  250. }
  251. .profile li{
  252. vertical-align: middle;
  253. }
  254. .profile li:first-child{
  255. width:120px
  256. }
  257. .profile li:last-child{
  258. width:calc(100% - 130px)
  259. }
  260. .money{
  261. display: inline-block;
  262. height: 30px;
  263. line-height: 30px;
  264. margin-right: 10px;
  265. text-align: center;
  266. border: 1px #ccc solid;
  267. border-radius: 5px;
  268. color: #666;
  269. font-size: 14px;
  270. width: 70px;
  271. }
  272. .money.active{
  273. background-color: #2319DC;
  274. color: #FFFFFF;
  275. border: 1px #2319DC solid;
  276. font-weight: 600;
  277. }
  278. </style>