activityDetail.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  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.heatValue}}</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. <vote-success ref="voteSuccess" @support="showShare"></vote-success>
  49. </view>
  50. </template>
  51. <script>
  52. import voteSuccess from "@/components/alert/voteSuccess.vue"
  53. import sharePopup from "@/components/alert/sharePopup.vue"
  54. import timelinePopup from "@/components/alert/timelinePopup.vue"
  55. import votePopup from '@/components/alert/votePopup.vue'
  56. import poster from "@/components/poster/poster.vue"
  57. import uqrcode from "@/components/uqrcode/uqrcode.vue"
  58. import smsAlert from "@/components/alert/smsAlert.vue"
  59. export default {
  60. components: {
  61. voteSuccess,
  62. smsAlert,
  63. sharePopup,
  64. timelinePopup,
  65. votePopup,
  66. poster,
  67. uqrcode
  68. },
  69. async onLoad(props) {
  70. this.isCustomBack=props.isCustomBack || true
  71. this.$refs.loading.showLoading()
  72. //作品id
  73. this.id = props.id;
  74. //获取详情
  75. await this.fetchData()
  76. //处理授权结果
  77. this.handelAuthResult(props)
  78. //处理创建订单结果
  79. this.handelOrderResult(props)
  80. //处理海报参数
  81. this.handelShareParams()
  82. //隐藏loading
  83. setTimeout(() => {
  84. this.hideLoading()
  85. }, 400)
  86. },
  87. computed: {
  88. content() {
  89. return decodeURIComponent(this.activity.content)
  90. }
  91. },
  92. data() {
  93. return {
  94. //是否自定义返回,防止授权时返回到webview页面
  95. isCustomBack:true,
  96. defaultAvatar:'https://vote.guosen-fumao.cn/obsfile/446d9e043f3748e4a47ea4d0de81b140-3b748fea4150c469b8eb66f98cd29e2.png',
  97. loading: false,
  98. //作品id
  99. id: '',
  100. //订单结果
  101. orderResult: {},
  102. //授权结果
  103. authResult: {},
  104. //分享
  105. qrCodeImg: '',
  106. //选中的道具
  107. selectGoods:{},
  108. posetrParams: {
  109. avatar: '',
  110. title: '我是普法帮帮代言人',
  111. subTitle: '邀请您为888号作品投票!'
  112. },
  113. activity: {},
  114. customStyle: {
  115. color: 'white',
  116. background: "#E72226",
  117. fontSize: '32rpx',
  118. width: '500rpx',
  119. margin: '25rpx auto'
  120. },
  121. }
  122. },
  123. methods: {
  124. hideLoading(){
  125. this.$refs.loading.hide()
  126. this.loading = false
  127. },
  128. async fetchData() {
  129. this.activity = (await this.$api.activity.getWorksDetail(this.id)).data.data
  130. },
  131. async handelShareParams() {
  132. console.log(this.activity.productNo);
  133. this.posetrParams = {
  134. avatar: this.defaultAvatar,
  135. title: '我是普法帮帮代言人',
  136. subTitle: '邀请您为'+this.activity.productNo+'号作品投票!'
  137. }
  138. let userId = this.vuex_userId || '000000' //游客
  139. let sharePath = '/pages/activity/activityDetail?id=' + this.activity.id + '&userId=' + userId
  140. let encodePath = encodeURIComponent(sharePath)
  141. this.$u.mpShare = {
  142. title: '我是普法帮帮代言人,' + this.posetrParams.subTitle,
  143. path: '/pages/index/home?path=' + encodePath,
  144. imageUrl: this.activity.imgUrl
  145. }
  146. let qrText = this.$config.PRODUCT_PATH + '?path=' + encodePath
  147. console.log(qrText);
  148. this.qrCodeImg = (await this.$refs.uqrcode.make({
  149. size: 150,
  150. text: qrText
  151. })).tempFilePath
  152. },
  153. handelAuthResult(options) {
  154. if (options.authResult == undefined) {
  155. return
  156. }
  157. this.authResult = JSON.parse(options.authResult)
  158. if (this.authResult.resultCode == '0000') {
  159. //授权成功,直接弹出礼物框
  160. this.hideLoading()
  161. this.showVote()
  162. return
  163. }
  164. if (this.authResult.resultCode == '9999') {
  165. //授权失败
  166. this.$refs.toast.error(this.authResult.message)
  167. return
  168. }
  169. },
  170. handelOrderResult(options) {
  171. if (options.orderPass&&this.$cache.get('orderResult')) {
  172. this.orderResult = this.$cache.get('orderResult')
  173. this.createOrder()
  174. }
  175. },
  176. async showVote() {
  177. this.$refs.votePopup.showVote(this.vuex_phone, this.id);
  178. },
  179. init() {
  180. if (this.vuex_phone) {
  181. this.showVote()
  182. }
  183. },
  184. //去投票
  185. toVote(item) {
  186. if (this.$cache.get('orderResult')) {
  187. this.orderResult=this.$cache.get('orderResult')
  188. this.orderResult.goodsId=item.id
  189. this.$cache.put('orderResult',this.orderResult,1*60*60)
  190. }
  191. this.selectGoods=item
  192. if (item.point == 0) {
  193. //免费投票
  194. this.freeVote()
  195. return
  196. }
  197. this.$refs.votePopup.hideVote()
  198. //移动积分投票,创建订单
  199. if (this.$cache.get('orderResult')) {
  200. this.createOrder()
  201. return
  202. }
  203. let params = {
  204. url: 'https://vote.guosen-fumao.cn/order.html',
  205. goodsId: this.selectGoods.id
  206. }
  207. this.$jump('/pages/webview/createOrder' + this.$u.queryParams(params))
  208. },
  209. //移动积分创建订单
  210. async createOrder() {
  211. if (this.$isEmpty(this.orderResult.fingerprint) ||
  212. this.$isEmpty(this.orderResult.sessionId) ||
  213. this.$isEmpty(this.orderResult.goodsId)) {
  214. this.$refs.toast.error('创建订单失败')
  215. return
  216. }
  217. let params = {
  218. fingerprint: this.orderResult.fingerprint,
  219. helpGoodsId: this.orderResult.goodsId,
  220. sessionId: this.orderResult.sessionId,
  221. num: 1,
  222. phone: this.vuex_phone,
  223. userId: this.vuex_userId
  224. }
  225. let res=await this.$api.order.create(params)
  226. if (res.data.success) {
  227. this.orderResult.outOrderId=res.data.data
  228. this.orderResult.mobile=this.vuex_phone
  229. console.log(this.orderResult,"/***********");
  230. this.$refs.smsAlert.showSmsAndSend(this.orderResult)
  231. }else{
  232. this.$refs.toast.error(res.data.msg)
  233. }
  234. },
  235. async cmccVote(item){
  236. this.$refs.smsAlert.hideSms()
  237. let params = {
  238. ...item,
  239. machinetype:'phone',
  240. productId:this.id,
  241. helpGoodsId: this.orderResult.goodsId,
  242. userId: this.vuex_userId,
  243. num: 1,
  244. }
  245. let res = await this.$api.order.exchange(params)
  246. if (res.data.success) {
  247. this.voteSuccess()
  248. this.$refs.smsAlert.hideSms()
  249. }else{
  250. this.$refs.toast.error(res.data.msg)
  251. }
  252. },
  253. voteSuccess(){
  254. try{
  255. let avatar=this.$cache.get('userInfo').avatar || this.defaultAvatar
  256. let voteCount=this.selectGoods.votePointRate
  257. let pointNum=this.vuex_active_setting.voteAndPointRate
  258. this.$refs.voteSuccess.showSuccess(avatar,voteCount,pointNum)
  259. }catch(e){
  260. this.$refs.toast.info('助力成功')
  261. }
  262. },
  263. async freeVote() {
  264. let params = {
  265. helpGoodsId: this.selectGoods.id,
  266. userId: this.vuex_userId,
  267. num: 1,
  268. productId: this.activity.id,
  269. }
  270. let res = await this.$api.order.exchange(params)
  271. if (res.data.success) {
  272. this.$refs.votePopup.hideVote()
  273. this.fetchData()
  274. let avatar=this.$cache.get('userInfo').avatar
  275. let voteCount=this.selectGoods.votePointRate
  276. let pointNum=this.vuex_active_setting.voteAndPointRate
  277. setTimeout(() => {
  278. this.voteSuccess()
  279. }, 200)
  280. } else {
  281. this.$refs.votePopup.hideVote()
  282. setTimeout(() => {
  283. this.$refs.toast.error(res.data.msg)
  284. }, 200)
  285. }
  286. },
  287. customBack() {
  288. if (this.isCustomBack==true) {
  289. uni.switchTab({
  290. url: '/pages/index/home'
  291. })
  292. }else{
  293. uni.navigateBack({
  294. delta:1
  295. })
  296. }
  297. },
  298. //分享
  299. async showPoster() {
  300. this.$refs.poster.showCanvas(this.qrCodeImg)
  301. },
  302. async shareConfirm(item) {
  303. if (item.name == '海报') {
  304. let params={
  305. activeId:this.activity.activeId,
  306. userId:this.vuex_userId
  307. }
  308. this.promoteNum= (await this.$api.activity.getPromoteNum(params)).data.data
  309. this.showPoster()
  310. return
  311. }
  312. if (item.name == '好友') {
  313. return
  314. }
  315. if (item.name == '朋友圈') {
  316. this.$refs.timelinePopup.show()
  317. }
  318. },
  319. showShare() {
  320. this.$refs.sharePopup.show()
  321. }
  322. },
  323. }
  324. </script>
  325. <style lang="scss" scoped>
  326. .works-video {
  327. width: 100%;
  328. height: 422rpx;
  329. }
  330. .title {
  331. padding: 20rpx;
  332. .work-no {
  333. padding: 5rpx 10rpx 5rpx 10rpx;
  334. border-radius: 7rpx;
  335. }
  336. .work-title {
  337. padding: 0 0 0 20rpx;
  338. color: #353535;
  339. font-size: 32rpx;
  340. font-weight: 800;
  341. }
  342. }
  343. .work-info-box {
  344. padding: 30rpx 0 15rpx 10rpx;
  345. .remen-icon {
  346. width: 30rpx;
  347. height: 30rpx;
  348. }
  349. .vote-count {
  350. padding: 0 40rpx 0 10rpx;
  351. font-size: 40rpx;
  352. color: #353535;
  353. font-weight: 800;
  354. }
  355. .work-rank {
  356. margin-left: -10rpx;
  357. color: #353535;
  358. background: #FDEBEC;
  359. border-radius: 21px 21px 21px 21px;
  360. font-size: 22rpx;
  361. padding: 8rpx 15rpx 8rpx 15rpx;
  362. }
  363. }
  364. .footer-bar {
  365. position: absolute;
  366. bottom: 0;
  367. left: 0;
  368. width: 100%;
  369. height: 170rpx;
  370. background-color: white;
  371. }
  372. .canvas-hide {
  373. position: fixed;
  374. right: 100vw;
  375. bottom: 100vh;
  376. z-index: -9999;
  377. opacity: 0;
  378. }
  379. </style>