votePopup.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. <template>
  2. <view>
  3. <u-popup v-model="show" mode="bottom" width="100%" height="750" border-radius="15" :closeable="true">
  4. <view class="padding-30">
  5. <view class="padding-top-20 text-bold text-xl">投票助力</view>
  6. <view
  7. style="color: #888888;font-size: 22rpx;font-family: PingFang-SC-Medium;line-height: 36rpx;padding: 20rpx 0;">
  8. {{voteContent()}}
  9. </view>
  10. <scroll-view style="white-space: nowrap;" :scroll-x="true">
  11. <view v-for="(item,index) in gitfs" :key="index" class="gift-item">
  12. <view @click.stop="selected = index;count = index" class="padding-20"
  13. :class="{'icon-box': true,'selected': index == selected}">
  14. <image mode="aspectFit" class="gift-img" :src="item.imgUrl"></image>
  15. <view class="gift-name text-cut-1">{{item.name}}</view>
  16. </view>
  17. <view style="color: #999999;font-size: 20rpx;text-align: center;padding-top: 10rpx;">
  18. {{item.activeVote==0? '剩余免费次数':'剩余次数'}} {{item.remainCount}}
  19. </view>
  20. </view>
  21. </scroll-view>
  22. <view class="handle-bar">
  23. <view v-if="pointNum>=0" class="text-center padding-bottom-20" style="color: #0A9FEF;">您目前的移动积分:
  24. {{pointNum}}
  25. </view>
  26. <view v-else class="text-center padding-bottom-20" style="color: #0A9FEF;">您目前的移动积分 <u-loading
  27. style="margin: 10rpx;" mode="circle"></u-loading>
  28. </view>
  29. <view class="button-bar">
  30. <view class="button-r">
  31. <u-count-to v-if="show" color="#E72226" start-val="0" :end-val="gitfs[selected].point"
  32. :duration="500"></u-count-to>
  33. <span class="info">移动积分</span>
  34. </view>
  35. <view class="button-f" @click="toVote">点击投票</view>
  36. </view>
  37. </view>
  38. </view>
  39. </u-popup>
  40. <toast ref="toast"></toast>
  41. <point-auth ref="pointAuth"></point-auth>
  42. <!-- #ifdef MP-WEIXIN -->
  43. <loading ref="loading" type="3" />
  44. <!-- #endif -->
  45. </view>
  46. </template>
  47. <script>
  48. import pointAuth from '../../components/alert/pointAuth.vue'
  49. export default {
  50. name: "votePopup",
  51. components: {
  52. pointAuth
  53. },
  54. data() {
  55. return {
  56. productId: 0,
  57. show: false,
  58. selected: 0,
  59. count: 0,
  60. pointNum: 0,
  61. gitfs: [],
  62. };
  63. },
  64. computed: {
  65. voteContent() {
  66. return data => {
  67. if (this.gitfs[this.selected] && this.gitfs[this.selected].content) {
  68. return this.gitfs[this.selected].content
  69. }
  70. return ''
  71. }
  72. }
  73. },
  74. methods: {
  75. hideLoading() {
  76. // #ifdef MP-WEIXIN
  77. this.$refs.loading.hide()
  78. // #endif
  79. // #ifndef MP-WEIXIN
  80. uni.hideLoading()
  81. // #endif
  82. },
  83. showLoading() {
  84. // #ifdef MP-WEIXIN
  85. this.$refs.loading.showLoading("礼物获取中")
  86. // #endif
  87. // #ifndef MP-WEIXIN
  88. this.$dialog.showLoading('礼物获取中')
  89. // #endif
  90. },
  91. async pointAuthClose() {
  92. this.hideLoading()
  93. await this.fetchGiftsData()
  94. this.show = true
  95. console.log(this.gitfs[this.selected].point);
  96. },
  97. async showVote(mobile, productId, activeId) {
  98. this.productId = productId
  99. this.activeId = activeId
  100. this.showLoading()
  101. let params = {
  102. mobile
  103. }
  104. let isCmcc = await this.checkIsCmcc()
  105. if (isCmcc) {
  106. const queryRes = (await this.$api.CMCC.queryCmccPoint(this.$u.queryParams(params)));
  107. if (queryRes.data.data.resultCode == '0001') {
  108. //去授权,保存作品id,方便跳转回来
  109. this.$cache.put('productId', this.productId)
  110. this.$refs.pointAuth.showAuth(queryRes.data.data.data);
  111. this.hideLoading()
  112. return;
  113. }
  114. const pointDetail = JSON.parse(queryRes.data.data.data);
  115. this.pointNum = pointDetail['points'];
  116. }
  117. await this.fetchGiftsData()
  118. this.hideLoading()
  119. this.show = true;
  120. },
  121. async checkIsCmcc() {
  122. if (this.$isEmpty(this.vuex_phone)) {
  123. return
  124. }
  125. let params = {
  126. phone: this.vuex_phone
  127. }
  128. // #ifdef MP-WEIXIN
  129. let res = await this.$api.CMCC.isCMCC(params)
  130. // #endif
  131. // #ifdef H5
  132. let res = await this.$api.CMCC.h5IsCMCC(params)
  133. // #endif
  134. console.log(res, "res....");
  135. return res.data.data
  136. },
  137. async fetchGiftsData() {
  138. let data = {
  139. activeId: this.activeId,
  140. productId: this.productId,
  141. userId: this.vuex_userId,
  142. }
  143. const res = await this.$api.activity.getGiftList(data);
  144. this.gitfs = res.data.data;
  145. },
  146. hideVote() {
  147. this.show = false;
  148. },
  149. toVote() {
  150. let item = this.gitfs[this.selected]
  151. if (this.pointNum == 0 && item.point != 0) {
  152. this.$u.toast('您无可用移动积分')
  153. return
  154. }
  155. if (item.remainCount == 0) {
  156. uni.showToast({
  157. duration: 2300,
  158. title: "您今日的助力票数已用完,每天0点后恢复。请继续助力您喜爱的作品!",
  159. icon: "none"
  160. })
  161. return
  162. }
  163. this.$emit('toVote', this.gitfs[this.selected])
  164. }
  165. }
  166. }
  167. </script>
  168. <style lang="scss" scoped>
  169. .gift-item {
  170. width: 150rpx;
  171. height: 250rpx;
  172. margin: 12rpx;
  173. // box-shadow: 0rpx 2rpx 2rpx 2rpx #DDDDDD;
  174. // background: #007AFF;
  175. display: inline-block;
  176. .icon-box {
  177. width: 150rpx;
  178. height: 200rpx;
  179. border: 1rpx solid #DDDDDD;
  180. box-shadow: 3rpx 3rpx 4rpx rgba(26, 26, 26, 0.2);
  181. border-radius: 10rpx;
  182. }
  183. .gift-img {
  184. width: 100rpx;
  185. height: 100rpx;
  186. border: 1rpx dashed #DDDDDD;
  187. padding: 10rpx;
  188. transition: border 0.5s;
  189. border: 0 solid transparent;
  190. }
  191. .selected {
  192. border: 2rpx solid #E72226;
  193. }
  194. .selected::before {
  195. content: "";
  196. position: absolute;
  197. margin-top: 147rpx;
  198. margin-left: 97rpx;
  199. border-radius: 5rpx 0 0 0;
  200. height: 30rpx;
  201. width: 30rpx;
  202. background: url(../../static/icon/selected.png) no-repeat center/22rpx red;
  203. }
  204. .gift-name {
  205. font-size: 22rpx;
  206. color: #353535;
  207. padding-top: 10rpx;
  208. }
  209. }
  210. .handle-bar {
  211. position: absolute;
  212. width: 100%;
  213. bottom: 0;
  214. left: 0;
  215. padding-bottom: 80rpx;
  216. .button-bar {
  217. width: 80%;
  218. height: 80rpx;
  219. border: 2rpx solid #E72226;
  220. margin: auto;
  221. border-radius: 100rpx;
  222. display: flex;
  223. .button-f {
  224. flex-basis: 50%;
  225. color: white;
  226. display: flex;
  227. font-size: 30rpx;
  228. justify-content: center;
  229. align-items: center;
  230. background: #E72226;
  231. border-radius: 0 100rpx 100rpx 0;
  232. }
  233. .button-r {
  234. color: #E82E3E;
  235. font-weight: 800;
  236. flex-basis: 50%;
  237. display: flex;
  238. font-size: 40rpx;
  239. justify-content: center;
  240. align-items: center;
  241. .info {
  242. color: #AAAAAA;
  243. font-weight: 500;
  244. margin-left: 15rpx;
  245. font-size: 22rpx;
  246. }
  247. }
  248. }
  249. }
  250. </style>