votePopup.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  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. console.log("config.baseURL",config.baseURL)
  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. },
  169. hideVote() {
  170. this.show = false;
  171. },
  172. toVote() {
  173. let item = this.gitfs[this.selected]
  174. if (this.pointNum == 0 && item.point != 0 && this.gitfs[this.selected].payType == 'POINT_EXCHANGE_GOODS') {
  175. this.$u.toast('您无可用移动积分')
  176. return
  177. }
  178. if (item.remainCount == 0) {
  179. uni.showToast({
  180. duration: 2300,
  181. title: "您今日的助力票数已用完,每天0点后恢复。请继续助力您喜爱的作品!",
  182. icon: "none"
  183. })
  184. return
  185. }
  186. this.$emit('toVote', this.gitfs[this.selected])
  187. }
  188. }
  189. }
  190. </script>
  191. <style lang="scss" scoped>
  192. .gift-item {
  193. width: 174rpx;
  194. height: 250rpx;
  195. margin: 12rpx;
  196. // box-shadow: 0rpx 2rpx 2rpx 2rpx #DDDDDD;
  197. // background: #007AFF;
  198. display: inline-block;
  199. .icon-box {
  200. width: 174rpx;
  201. height: 200rpx;
  202. border: 1rpx solid #DDDDDD;
  203. box-shadow: 3rpx 3rpx 4rpx rgba(26, 26, 26, 0.2);
  204. border-radius: 10rpx;
  205. display: flex;
  206. flex-direction: column;
  207. align-items: center;
  208. }
  209. .gift-img {
  210. width: 100rpx;
  211. height: 100rpx;
  212. border: 1rpx dashed #DDDDDD;
  213. padding: 10rpx;
  214. transition: border 0.5s;
  215. border: 0 solid transparent;
  216. }
  217. .selected {
  218. border: 2rpx solid var(--bgColor);
  219. position: relative;
  220. }
  221. .selected::before {
  222. content: "";
  223. position: absolute;
  224. bottom: 0;
  225. right: -2rpx;
  226. border-radius: 10rpx 0 10rpx 0;
  227. height: 30rpx;
  228. width: 30rpx;
  229. background: url(../../static/icon/selected.png) no-repeat center/22rpx var(--bgColor);
  230. }
  231. .gift-name {
  232. font-size: 22rpx;
  233. color: #353535;
  234. padding-top: 10rpx;
  235. }
  236. }
  237. .handle-bar {
  238. position: absolute;
  239. width: 100%;
  240. bottom: 0;
  241. left: 0;
  242. padding-bottom: 80rpx;
  243. .button-bar {
  244. width: 80%;
  245. height: 80rpx;
  246. border: 2rpx solid var(--bgColor);
  247. margin: auto;
  248. border-radius: 100rpx;
  249. display: flex;
  250. .button-f {
  251. flex-basis: 50%;
  252. color: white;
  253. display: flex;
  254. font-size: 30rpx;
  255. justify-content: center;
  256. align-items: center;
  257. background: var(--bgColor);
  258. border-radius: 0 100rpx 100rpx 0;
  259. }
  260. .button-r {
  261. color: var(--bgColor);
  262. font-weight: 800;
  263. flex-basis: 50%;
  264. display: flex;
  265. font-size: 40rpx;
  266. justify-content: center;
  267. align-items: center;
  268. .info {
  269. color: #AAAAAA;
  270. font-weight: 500;
  271. margin-left: 15rpx;
  272. font-size: 22rpx;
  273. }
  274. }
  275. }
  276. }
  277. </style>