votePopup.vue 7.5 KB

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