votePopup.vue 7.0 KB

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