index.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. <template>
  2. <div class="page-taptapstar">
  3. <div class="bg-mask"></div>
  4. <div class="box-shop-wrap">
  5. <div class="box-shop">
  6. <div class="box-hd">
  7. <ul>
  8. <li :class='[{"active":selectIndex==1}]' @click="changeType(1)">推荐</li>
  9. <li :class='[{"active":selectIndex==2}]' @click="changeType(2)">钻石</li>
  10. <li :class='[{"active":selectIndex==3}]' @click="changeType(3)">金币</li>
  11. <li :class='[{"active":selectIndex==4}]' @click="changeType(4)">礼包</li>
  12. </ul>
  13. </div>
  14. <div class="box-bd">
  15. <div :class='["tab-panel",{"active":selectIndex==1}]'>
  16. <ul class="list-recommend">
  17. <li class="recommend-item bg0" v-for="(item,index) in recommendList" :key="index" v-if="index==0||index>=3">
  18. <div class="item-fl">
  19. <img :class="['item-pic','pic'+item.picId]" :src='""+picUrl+item.picId+".png"'/>
  20. <div class="item-cont">
  21. <h3>{{item.name}}</h3>
  22. <p>{{item.desc}}</p>
  23. </div>
  24. </div>
  25. <div class="item-btn ext-buy" v-if="index>=3" @click="handlePay(item.id,1)">
  26. ¥ {{item.price/100}}
  27. </div>
  28. <div class="item-btn" @click="showPopupBook(true)" v-else>
  29. 订阅<br>查看详情内容
  30. </div>
  31. </li>
  32. </ul>
  33. </div>
  34. <div :class='["tab-panel",{"active":selectIndex==2}]'>
  35. <ul class="list-gold">
  36. <li class="gold-item" v-for="(item,index) in diamondList" :key="index">
  37. <img :class="['item-pic','pic'+item.picId]" :src='""+picUrl+item.picId+".png"'/>
  38. <button class="item-btn" @click="handlePay(item.id,1)">¥ {{item.price/100}}</button>
  39. </li>
  40. </ul>
  41. </div>
  42. <div :class='["tab-panel",{"active":selectIndex==3}]'>
  43. <ul class="list-gold">
  44. <li class="gold-item" v-for="(item,index) in goldList" :key="index">
  45. <img :class="['item-pic','pic'+item.picId]" :src='""+picUrl+item.picId+".png"'/>
  46. <p>{{item.desc}}</p>
  47. <button class="item-btn" @click="handlePay(item.id,1)">¥ {{item.price/100}}</button>
  48. </li>
  49. </ul>
  50. </div>
  51. <div :class='["tab-panel",{"active":selectIndex==4}]'>
  52. <ul class="list-recommend">
  53. <li :class="['recommend-item','bg'+index]" v-for="(item,index) in giftList" :key="index">
  54. <div class="item-fl">
  55. <img :class="['item-pic','pic'+item.picId]" :src='""+picUrl+item.picId+".png"'/>
  56. <div class="item-cont">
  57. <h3>{{item.name}}</h3>
  58. <p>{{item.desc}}</p>
  59. </div>
  60. </div>
  61. <div class="item-btn ext-buy" @click="showPopupGift(true,index)">
  62. ¥ {{item.price/100}}
  63. </div>
  64. </li>
  65. </ul>
  66. </div>
  67. </div>
  68. </div>
  69. </div>
  70. <div :class='["popup popup-book",{"active":isShowPopupBook}]'>
  71. <div class="bg-mask"></div>
  72. <div class="box-pop-wrap">
  73. <div class="box-pop">
  74. <h3 class="box-pop_title"><img src="@/img/taptapstar/recommend_title1.png" alt=""></h3>
  75. <img class="book-pic" src="@/img/taptapstar/popup_logo.png" alt="">
  76. <p class="book-desc" v-for="(item,index) in recommendPlanList" :key="index" v-if="index==0">{{item.desc}}</p>
  77. <ul class="list-book">
  78. <li :class="['book-item',{'ext-recommend':index==1}]" v-for="(item,index) in recommendPlanList" :key="index"
  79. @click="handlePay(item.id,1)">
  80. <h3 v-if="index==0">月使用权</h3>
  81. <h3 v-else-if="index==1">周使用权</h3>
  82. <h3 v-else>年使用权</h3>
  83. <p>¥ {{item.price/100}}</p>
  84. </li>
  85. </ul>
  86. <button @click="showPopupBook(false)" class="btn-close"></button>
  87. </div>
  88. </div>
  89. </div>
  90. <div :class='["popup popup-first",{"active":isShowPopupFirst}]'>
  91. <div class="bg-mask"></div>
  92. <div class="box-pop-wrap">
  93. <div class="box-pop">
  94. <h2></h2>
  95. <ul class="list-first">
  96. <li class="first-item active">
  97. <img src="@/img/taptapstar/diamond_dis1.png" alt="" class="item-pic">
  98. </li>
  99. <li class="first-item">
  100. <img src="@/img/taptapstar/diamond_dis2.png" alt="" class="item-pic">
  101. </li>
  102. <li class="first-item">
  103. <img src="@/img/taptapstar/diamond_dis3.png" alt="" class="item-pic">
  104. </li>
  105. <li class="first-item">
  106. <img src="@/img/taptapstar/diamond_dis4.png" alt="" class="item-pic">
  107. </li>
  108. </ul>
  109. <p>2倍<span>仅一次</span>领取机会</p>
  110. <button class="btn-buy">购买</button>
  111. </div>
  112. <button class="box-pop_close" @click="showPopupFirst(false)"></button>
  113. </div>
  114. </div>
  115. <div :class='["popup popup-gift",{"active":isShowPopupGift}]'>
  116. <div class="bg-mask"></div>
  117. <div class="box-pop-wrap">
  118. <div class="box-pop">
  119. <h3 class="box-pop_title">{{giftInfo.name}}</h3>
  120. <div class="star-wrap">
  121. <img :src='""+picUrl+"stand_"+giftInfo.picId+".png"'/>
  122. </div>
  123. <p>{{giftInfo.desc}}</p>
  124. <button class="btn-buy" @click="handlePay(giftInfo.id,1)">购买</button>
  125. </div>
  126. <button class="box-pop_close" @click="showPopupGift(false)"></button>
  127. </div>
  128. </div>
  129. </div>
  130. </template>
  131. <script>
  132. import lib from 'lib'
  133. import axios from 'axios'
  134. import {Indicator, Toast, MessageBox} from 'mint-ui';
  135. import pay from 'pay';
  136. export default {
  137. data () {
  138. return {
  139. picUrl: lib.domain+"/build/img/taptapstar/",
  140. appid: lib.getParam('dwAppId'),
  141. isShowPopupBook: false,
  142. isShowPopupFirst: false,
  143. isShowPopupGift: false,
  144. selectIndex:1, //1推荐2钻石3金币4礼包
  145. listName : ["","recommendList","diamondList","goldList","giftList"],
  146. recommendList : [], //推荐列表
  147. recommendPlanList : [], //推荐购买列表
  148. diamondList : [], //钻石列表
  149. goldList : [], //金币列表
  150. giftList : [], //礼包列表
  151. giftInfo : {}, //礼包信息
  152. tradeNo: "", //小游戏支付交易的订单号
  153. }
  154. },
  155. mounted () {
  156. this.getGoodsInfo();
  157. },
  158. methods:{
  159. changeType(index){
  160. this.selectIndex = index;
  161. if(this[this.listName[this.selectIndex]].length==0) {
  162. this.getGoodsInfo();
  163. }
  164. },
  165. showPopupBook(flag){
  166. this.isShowPopupBook = flag;
  167. },
  168. showPopupFirst(flag){
  169. this.isShowPopupFirst = flag;
  170. },
  171. showPopupGift(flag,index=0){
  172. this.isShowPopupGift = flag;
  173. this.giftInfo = this.giftList[index];
  174. },
  175. getGoodsInfo(){
  176. let url = `${lib.apiUrl}/product/${this.appid}/products/${this.selectIndex}`;
  177. Indicator.open();
  178. axios.get(url,{
  179. dwAppId : this.appid,
  180. type : this.selectIndex
  181. }).then(({data}) => {
  182. Indicator.close();
  183. this[this.listName[this.selectIndex]] = data.data.list;
  184. if(this.selectIndex==1 && this.recommendList.length>=3 ){ //推荐
  185. this.recommendPlanList = [
  186. this.recommendList[1],
  187. this.recommendList[0],
  188. this.recommendList[2]
  189. ]
  190. }
  191. if(this.selectIndex==4) { //礼包
  192. this.giftInfo = this.giftList[0];
  193. }
  194. }).catch(({data}) => {
  195. Indicator.close();
  196. })
  197. },
  198. handlePay(productId,productCount=1){
  199. pay.handlePay(productId,productCount);
  200. }
  201. }
  202. }
  203. </script>
  204. <style lang="scss">
  205. @import "./scss/taptapstar.scss";
  206. </style>