activityDetail.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. <template>
  2. <view :style="vuex_skin">
  3. <u-navbar :custom-back="customBack" :is-back="true" title="作品详情"></u-navbar>
  4. <view class="" v-show="!loading">
  5. <video class="works-video" :autoplay="true" :src="activity.videoUrl"></video>
  6. <view style="padding: 20rpx 30rpx 50rpx 30rpx;background: white;">
  7. <view class="title" style="border-bottom: 1rpx solid #EEEEEE ;">
  8. <span class="bg-red work-no"> {{activity.productNo}}号</span>
  9. <span class="work-title">{{activity.title}}</span>
  10. <view class="work-info-box">
  11. <image class="remen-icon" src="../../static/icon/remen.png"></image>
  12. <span class="vote-count">{{activity.voteCount}}</span>
  13. <span class="work-rank">排行榜第{{activity.rank}}名</span>
  14. </view>
  15. </view>
  16. <view style="font-size: 24rpx;color: #888888;padding: 30rpx 10rpx 20rpx 10rpx;">
  17. <u-parse :html="content"></u-parse>
  18. </view>
  19. </view>
  20. <view @click="showShare" class="bg-white padding-30 margin-top-30 flex">
  21. <view class="basis-xs">
  22. <image style="width: 84rpx;height: 84rpx;" src="../../static/icon/ic_zhuanfa.png"></image>
  23. </view>
  24. <view class="basis-lg flex flex-direction" style="margin-left: -20rpx;">
  25. <view style="font-size: 28rpx;color: #353535;">转发邀请投票</view>
  26. <view style="font-size: 22rpx;color: #AEACAF;padding-top: 10rpx;">
  27. 成功邀请一位好友投票,获得{{vuex_active_setting.voteAndHeatRate}}热力值</view>
  28. </view>
  29. <view class="flex justify-center align-center"
  30. style="color: #666666;flex-basis: 20%;font-size: 26rpx;font-family: PingFang-SC-Medium;">去邀请 >
  31. </view>
  32. </view>
  33. <view class="footer-bar" style="z-index: 1;">
  34. <u-button @click="login" shape="circle" :custom-style="customStyle">给ta投票</u-button>
  35. </view>
  36. </view>
  37. <login ref="login" @signIn="signIn" @phoneSuccess="showVote"></login>
  38. <toast ref="toast"></toast>
  39. <loading ref="loading" type="3" theme="2" />
  40. <vote-popup ref="votePopup" @toVote="toVote"></vote-popup>
  41. <!-- 海报 -->
  42. <poster ref="poster" :avatar="posetrParams.avatar" :title="posetrParams.title"
  43. :subTitle="posetrParams.subTitle"></poster>
  44. <uqrcode class="canvas-hide" ref="uqrcode"></uqrcode>
  45. <share-popup ref="sharePopup" @confirm="shareConfirm"></share-popup>
  46. <timeline-popup ref="timelinePopup"></timeline-popup>
  47. <sms-alert ref="smsAlert" @exchange="cmccVote"></sms-alert>
  48. </view>
  49. </template>
  50. <script>
  51. import sharePopup from "@/components/alert/sharePopup.vue"
  52. import timelinePopup from "@/components/alert/timelinePopup.vue"
  53. import votePopup from '@/components/alert/votePopup.vue'
  54. import poster from "@/components/poster/poster.vue"
  55. import uqrcode from "@/components/uqrcode/uqrcode.vue"
  56. import smsAlert from "@/components/alert/smsAlert.vue"
  57. export default {
  58. components: {
  59. smsAlert,
  60. sharePopup,
  61. timelinePopup,
  62. votePopup,
  63. poster,
  64. uqrcode
  65. },
  66. async onLoad(props) {
  67. this.$refs.loading.showLoading()
  68. //作品id
  69. this.id = props.id;
  70. //获取详情
  71. this.fetchData()
  72. //处理授权结果
  73. this.handelAuthResult(props)
  74. //处理创建订单结果
  75. this.handelOrderResult(props)
  76. //隐藏loading
  77. setTimeout(() => {
  78. this.$refs.loading.hide()
  79. this.loading = false
  80. }, 400)
  81. },
  82. onReady() {
  83. //处理海报参数
  84. this.handelShareParams()
  85. },
  86. computed: {
  87. content() {
  88. return decodeURIComponent(this.activity.content)
  89. }
  90. },
  91. data() {
  92. return {
  93. loading: false,
  94. //作品id
  95. id: '',
  96. //订单结果
  97. orderResult: {},
  98. //授权结果
  99. authResult: {},
  100. //分享
  101. qrCodeImg: '',
  102. //选中的道具
  103. selectGoods:{},
  104. posetrParams: {
  105. avatar: '',
  106. title: '我是普法帮帮代言人',
  107. subTitle: '邀请您为888号作品投票!'
  108. },
  109. activity: {},
  110. customStyle: {
  111. color: 'white',
  112. background: "#E72226",
  113. fontSize: '32rpx',
  114. width: '500rpx',
  115. margin: '25rpx auto'
  116. },
  117. }
  118. },
  119. methods: {
  120. async fetchData() {
  121. this.activity = (await this.$api.activity.getWorksDetail(this.id)).data.data
  122. },
  123. async handelShareParams() {
  124. this.posetrParams = {
  125. avatar: 'https://gx.vote.activity.obs.cn-south-1.myhuaweicloud.com:443/446d9e043f3748e4a47ea4d0de81b140-3b748fea4150c469b8eb66f98cd29e2.png',
  126. title: '我是普法帮帮代言人',
  127. subTitle: '邀请您为'+this.activity.productNo+'号作品投票!'
  128. }
  129. let userId = this.vuex_userId || '000000' //游客
  130. let sharePath = '/pages/activity/activityDetail?id=' + this.activity.id + '&userId=' + userId
  131. let encodePath = encodeURIComponent(sharePath)
  132. this.$u.mpShare = {
  133. title: '我是普法帮帮代言人,' + this.posetrParams.subTitle,
  134. path: '/pages/index/home?path=' + encodePath,
  135. imageUrl: ''
  136. }
  137. let qrText = this.$config.PRODUCT_PATH + '?path=' + encodePath
  138. this.qrCodeImg = (await this.$refs.uqrcode.make({
  139. size: 150,
  140. text: qrText
  141. })).tempFilePath
  142. },
  143. handelAuthResult(options) {
  144. if (options.authResult == undefined) {
  145. return
  146. }
  147. this.authResult = JSON.parse(options.authResult)
  148. if (this.authResult.resultCode == '0000') {
  149. //授权成功,直接弹出礼物框
  150. this.showVote()
  151. return
  152. }
  153. if (this.authResult.resultCode == '9999') {
  154. //授权失败
  155. this.$refs.toast.error(this.authResult.message)
  156. return
  157. }
  158. },
  159. handelOrderResult(options) {
  160. if (options.orderPass&&this.$cache.get('orderResult')) {
  161. this.orderResult = this.$cache.get('orderResult')
  162. this.createOrder()
  163. }
  164. },
  165. async showVote() {
  166. this.$refs.votePopup.showVote(this.vuex_phone, this.id);
  167. },
  168. init() {
  169. if (this.vuex_phone) {
  170. this.showVote()
  171. }
  172. },
  173. //去投票
  174. toVote(item) {
  175. if (this.$cache.get('orderResult')) {
  176. this.orderResult=this.$cache.get('orderResult')
  177. this.orderResult.goodsId=item.id
  178. }
  179. this.selectGoods=item
  180. if (item.point == 0) {
  181. //免费投票
  182. this.freeVote()
  183. return
  184. }
  185. this.$refs.votePopup.hideVote()
  186. //移动积分投票,创建订单
  187. if (this.$cache.get('orderResult')) {
  188. this.createOrder()
  189. return
  190. }
  191. let params = {
  192. url: 'https://vote.guosen-fumao.cn/order.html',
  193. goodsId: this.selectGoods.id
  194. }
  195. this.$jump('/pages/webview/createOrder' + this.$u.queryParams(params))
  196. },
  197. //移动积分创建订单
  198. async createOrder() {
  199. if (this.$isEmpty(this.orderResult.fingerprint) ||
  200. this.$isEmpty(this.orderResult.sessionId) ||
  201. this.$isEmpty(this.orderResult.goodsId)) {
  202. this.$refs.toast.error('创建订单失败')
  203. return
  204. }
  205. let params = {
  206. fingerprint: this.orderResult.fingerprint,
  207. helpGoodsId: this.orderResult.goodsId,
  208. sessionId: this.orderResult.sessionId,
  209. num: 1,
  210. phone: this.vuex_phone,
  211. userId: this.vuex_userId
  212. }
  213. let res=await this.$api.order.create(params)
  214. if (res.data.success) {
  215. this.orderResult.outOrderId=res.data.data
  216. this.orderResult.mobile=this.vuex_phone
  217. console.log(this.orderResult,"/***********");
  218. this.$refs.smsAlert.showSmsAndSend(this.orderResult)
  219. }else{
  220. this.$refs.toast.error(res.data.msg)
  221. }
  222. },
  223. async cmccVote(item){
  224. this.$refs.smsAlert.hideSms()
  225. let params = {
  226. ...item,
  227. machinetype:'phone',
  228. productId:this.id,
  229. helpGoodsId: this.orderResult.goodsId,
  230. userId: this.vuex_userId,
  231. num: 1,
  232. }
  233. let res = await this.$api.order.exchange(params)
  234. if (res.data.success) {
  235. this.$refs.toast.info('助力成功')
  236. }else{
  237. this.$refs.toast.error(res.data.msg)
  238. }
  239. },
  240. async freeVote() {
  241. let params = {
  242. helpGoodsId: this.selectGoods.id,
  243. userId: this.vuex_userId,
  244. num: 1,
  245. productId: this.activity.id,
  246. }
  247. let res = await this.$api.order.exchange(params)
  248. if (res.data.success) {
  249. this.$refs.votePopup.hideVote()
  250. this.fetchData()
  251. setTimeout(() => {
  252. this.$refs.toast.info("助力成功")
  253. }, 200)
  254. } else {
  255. this.$refs.votePopup.hideVote()
  256. setTimeout(() => {
  257. this.$refs.toast.error(res.data.msg)
  258. }, 200)
  259. }
  260. },
  261. customBack() {
  262. uni.switchTab({
  263. url: '/pages/index/home'
  264. })
  265. },
  266. //分享
  267. async showPoster() {
  268. this.$refs.poster.showCanvas(this.qrCodeImg)
  269. },
  270. shareConfirm(item) {
  271. if (item.name == '海报') {
  272. this.showPoster()
  273. return
  274. }
  275. if (item.name == '好友') {
  276. return
  277. }
  278. if (item.name == '朋友圈') {
  279. this.$refs.timelinePopup.show()
  280. }
  281. },
  282. showShare() {
  283. this.$refs.sharePopup.show()
  284. }
  285. },
  286. }
  287. </script>
  288. <style lang="scss" scoped>
  289. .works-video {
  290. width: 100%;
  291. height: 422rpx;
  292. }
  293. .title {
  294. padding: 20rpx;
  295. .work-no {
  296. padding: 5rpx 10rpx 5rpx 10rpx;
  297. border-radius: 7rpx;
  298. }
  299. .work-title {
  300. padding: 0 0 0 20rpx;
  301. color: #353535;
  302. font-size: 32rpx;
  303. font-weight: 800;
  304. }
  305. }
  306. .work-info-box {
  307. padding: 30rpx 0 15rpx 10rpx;
  308. .remen-icon {
  309. width: 30rpx;
  310. height: 30rpx;
  311. }
  312. .vote-count {
  313. padding: 0 40rpx 0 10rpx;
  314. font-size: 40rpx;
  315. color: #353535;
  316. font-weight: 800;
  317. }
  318. .work-rank {
  319. margin-left: -10rpx;
  320. color: #353535;
  321. background: #FDEBEC;
  322. border-radius: 21px 21px 21px 21px;
  323. font-size: 22rpx;
  324. padding: 8rpx 15rpx 8rpx 15rpx;
  325. }
  326. }
  327. .footer-bar {
  328. position: absolute;
  329. bottom: 0;
  330. left: 0;
  331. width: 100%;
  332. height: 170rpx;
  333. background-color: white;
  334. }
  335. .canvas-hide {
  336. position: fixed;
  337. right: 100vw;
  338. bottom: 100vh;
  339. z-index: -9999;
  340. opacity: 0;
  341. }
  342. </style>