activityDetail.vue 11 KB

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