activityDetail.vue 11 KB

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