activityDetail.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785
  1. <template>
  2. <view :style="vuex_skin">
  3. <!-- #ifdef MP-WEIXIN -->
  4. <u-navbar :custom-back="customBack" :is-back="true" title="作品详情"></u-navbar>
  5. <!-- #endif -->
  6. <view class="" v-show="!loading" style="padding-bottom: 250rpx;">
  7. <video v-if="activity.activeType == 'VIDEO_TEXT'" class="works-video" @error="videoError"
  8. :poster="activity.imgUrl" :src="activity.videoUrl"></video>
  9. <image v-else class="works-video" @click="$util.preview(activity.imgUrl)" :src="activity.imgUrl"
  10. mode="widthFix">
  11. </image>
  12. <view style="padding: 20rpx 30rpx 50rpx 30rpx;background: white;">
  13. <view class="title" style="border-bottom: 1rpx solid #EEEEEE ;">
  14. <span class="bg-base work-no"> {{activity.productNo}}号</span>
  15. <span class="work-title">{{activity.title}}</span>
  16. <view class="work-info-box" style="display: flex;">
  17. <view class="center">
  18. <text class="cuIcon-hotfill text-base" style="font-size: 36rpx;"></text>
  19. </view>
  20. <view class="vote-count">{{activity.voteCount}}</view>
  21. <view class="center" style="justify-content: flex-start;">
  22. <view class="cu-tag round sm bg-tag" style="font-size: 22rpx;">
  23. <text>排行榜第{{activity.rank}}名</text>
  24. </view>
  25. </view>
  26. <!-- <view class="work-rank" style="background-color: rgba(102, 73, 239,.2);">排行榜第{{activity.rank}}名</view> -->
  27. </view>
  28. </view>
  29. <view style="font-size: 24rpx;color: #888888;padding: 30rpx 10rpx 20rpx 10rpx;">
  30. <u-parse :html="content"></u-parse>
  31. </view>
  32. </view>
  33. <view @click="showShare" class="bg-white padding-30 margin-top-30 flex">
  34. <view class="center margin-left-20">
  35. <view class="bg-base cu-btn round cuIcon" style="width: 70rpx;height: 70rpx;">
  36. <text class="cuIcon-forwardfill"></text>
  37. </view>
  38. <!-- <image style="width: 84rpx;height: 84rpx;" src="../../static/icon/ic_zhuanfa.png"></image> -->
  39. </view>
  40. <view class="basis-lg flex flex-direction" style="margin-left: 30rpx;">
  41. <view style="font-size: 28rpx;color: #353535;">为TA拉票</view>
  42. <view style="font-size: 22rpx;color: #AEACAF;padding-top: 10rpx;">
  43. <!-- <text>成功邀请一位好友投票,获得{{vuex_active_setting.voteAndHeatRate}}热力值</text> -->
  44. <text>转发邀请好友为该作品助力</text>
  45. </view>
  46. </view>
  47. <view class="flex justify-center align-center"
  48. style="color: #666666;flex-basis: 20%;font-size: 26rpx;font-family: PingFang-SC-Medium;">去邀请 >
  49. </view>
  50. </view>
  51. <view class="footer-bar" style="z-index: 1;">
  52. <u-button @click="goVote" shape="circle" :custom-style="btnText=='给ta投票'?customStyle:disabledStyle">
  53. {{btnText}}
  54. </u-button>
  55. </view>
  56. </view>
  57. <login ref="login" @signIn="signIn" @phoneSuccess="showVote"></login>
  58. <toast ref="toast"></toast>
  59. <!-- #ifdef MP-WEIXIN -->
  60. <loading ref="loading" type="3" theme="2" />
  61. <!-- #endif -->
  62. <vote-popup ref="votePopup" @toVote="toVote"></vote-popup>
  63. <!-- 海报 -->
  64. <poster v-if="$isNotEmpty(posetrParams.activeId)" ref="poster" :avatar="posetrParams.avatar"
  65. :activeId="posetrParams.activeId" :title="posetrParams.title" :subTitle="posetrParams.subTitle"></poster>
  66. <share-popup ref="sharePopup" @confirm="shareConfirm"></share-popup>
  67. <timeline-popup ref="timelinePopup"></timeline-popup>
  68. <sms-alert ref="smsAlert" @exchange="cmccVote"></sms-alert>
  69. <vote-success ref="voteSuccess" @support="skipShop"></vote-success>
  70. <home-btn></home-btn>
  71. <webAuthAlert ref="webAuthAlert" tipsContent="首次现金投票助力需用户授权" @confirm="webAuthConfirm"></webAuthAlert>
  72. <verificationCodeAlert ref="verificationCodeAlert" :codeImg="verificationCodeImg" @handleRefreshCode="getVerificationCode" @confirm="codeConfirm"></verificationCodeAlert>
  73. </view>
  74. </template>
  75. <script>
  76. import voteSuccess from "@/components/alert/voteSuccess.vue"
  77. import sharePopup from "@/components/alert/sharePopup.vue"
  78. import timelinePopup from "@/components/alert/timelinePopup.vue"
  79. import votePopup from '@/components/alert/votePopup.vue'
  80. import poster from "@/components/poster/poster.vue"
  81. import smsAlert from "@/components/alert/smsAlert.vue"
  82. import webAuthAlert from "@/components/alert/webAuthAlert.vue"
  83. import verificationCodeAlert from '@/components/alert/verificationCodeAlert.vue'
  84. export default {
  85. components: {
  86. voteSuccess,
  87. smsAlert,
  88. sharePopup,
  89. timelinePopup,
  90. votePopup,
  91. poster,
  92. webAuthAlert,
  93. verificationCodeAlert
  94. },
  95. async onLoad(props) {
  96. // #ifdef MP-WEIXIN
  97. uni.showShareMenu({
  98. menus: ['shareAppMessage', 'shareTimeline']
  99. })
  100. // #endif
  101. this.isCustomBack = props.isCustomBack || true
  102. this.showLoading()
  103. //作品id
  104. this.id = props.id;
  105. //获取详情
  106. await this.fetchData()
  107. //处理授权结果
  108. this.handelAuthResult(props)
  109. // #ifdef MP-WEIXIN
  110. //处理创建订单结果
  111. this.handelOrderResult(props)
  112. // #endif
  113. // #ifdef H5
  114. this.h5CreateOrder()
  115. // #endif
  116. //处理海报参数
  117. this.handelShareParams()
  118. //隐藏loading
  119. setTimeout(() => {
  120. this.hideLoading()
  121. }, 20)
  122. this.getActivitySetting();
  123. },
  124. onShow(){},
  125. computed: {
  126. content() {
  127. return decodeURIComponent(this.activity.content)
  128. },
  129. btnText: {
  130. get() {
  131. let now = new Date().getTime()
  132. let startTime = this.$dateTime.getTime(this.activity.activeStartTime)
  133. let endTime = this.$dateTime.getTime(this.activity.activeEndTime)
  134. if (now < startTime) {
  135. return "活动未开始"
  136. }
  137. if (now > endTime) {
  138. return "活动已结束"
  139. }
  140. return "给ta投票"
  141. }
  142. }
  143. },
  144. data() {
  145. return {
  146. count: 0,
  147. //是否自定义返回,防止授权时返回到webview页面
  148. isCustomBack: true,
  149. defaultAvatar: 'https://vote.guosen-fumao.cn/obsfile/446d9e043f3748e4a47ea4d0de81b140-3b748fea4150c469b8eb66f98cd29e2.png',
  150. loading: false,
  151. //作品id
  152. id: '',
  153. //订单结果
  154. orderResult: {},
  155. //授权结果
  156. authResult: {},
  157. //分享
  158. qrCodeImg: '',
  159. //选中的道具
  160. selectGoods: {},
  161. mpShare: {},
  162. posetrParams: {
  163. avatar: '',
  164. title: '我是普法帮帮代言人',
  165. subTitle: '邀请您为888号作品投票!',
  166. activeId: ''
  167. },
  168. activity: {},
  169. customStyle: {
  170. color: 'white',
  171. background: "#ffffff",
  172. fontSize: '32rpx',
  173. width: '500rpx',
  174. margin: '25rpx auto'
  175. },
  176. disabledStyle: {
  177. background: "#f1f1f1",
  178. fontSize: '32rpx',
  179. width: '500rpx',
  180. margin: '25rpx auto'
  181. },
  182. //活动设置
  183. activitySetting: {},
  184. //验证码图片
  185. verificationCodeImg: ''
  186. }
  187. },
  188. onShareAppMessage(res) {
  189. return {
  190. title: `${this.$isNotEmpty(this.activitySetting.pullVoteParam) ? `【${this.activitySetting.pullVoteParam.sponsor}】` : ``}${this.mpShare.title}`,
  191. path: this.mpShare.path,
  192. imageUrl: this.mpShare.imageUrl
  193. }
  194. },
  195. onShareTimeline(res) {
  196. return {
  197. title: `${this.$isNotEmpty(this.activitySetting.pullVoteParam) ? `【${this.activitySetting.pullVoteParam.sponsor}】` : ``}${this.mpShare.title}`,
  198. path: this.mpShare.path,
  199. imageUrl: this.mpShare.imageUrl
  200. }
  201. },
  202. methods: {
  203. goVote() {
  204. if (this.btnText == '给ta投票') {
  205. this.login()
  206. return
  207. }
  208. this.$refs.toast.error(this.btnText)
  209. },
  210. showLoading() {
  211. // #ifdef MP-WEIXIN
  212. this.$refs.loading.showLoading()
  213. // #endif
  214. // #ifndef MP-WEIXIN
  215. this.$dialog.showLoading()
  216. // #endif
  217. },
  218. videoError(e) {
  219. console.log(e, "error");
  220. },
  221. hideLoading() {
  222. // #ifdef MP-WEIXIN
  223. this.$refs.loading.hide()
  224. // #endif
  225. // #ifndef MP-WEIXIN
  226. uni.hideLoading()
  227. // #endif
  228. this.loading = false
  229. },
  230. async fetchData() {
  231. this.activity = (await this.$api.activity.getWorksDetail(this.id)).data.data
  232. },
  233. async handelShareParams() {
  234. let title = await this.getPosetrParamsTitle();
  235. const userInfo = uni.getStorageSync("userInfo");
  236. /**
  237. * 海报分享参数
  238. * avatar: 显示优先级:作品封面 >>> 用户头像 >>> 默认头像
  239. * title: 显示优先级:平台自定义标题 >>> 我是第X号大赛代言人!>>> 我是普法帮帮代言人!
  240. */
  241. this.posetrParams = {
  242. avatar: this.activity.imgUrl || userInfo.avatar || this.defaultAvatar,
  243. title: this.activitySetting.pullVoteParam.title || title,
  244. subTitle: '邀请您为' + this.activity.productNo + '号作品投票!',
  245. activeId: this.activity.activeId
  246. }
  247. let userId = this.vuex_userId || '000000' //游客
  248. let sharePath = '/pages/activity/activityDetail?id=' + this.activity.id + '&userId=' + userId
  249. let encodePath = encodeURIComponent(sharePath)
  250. /**
  251. * 小程序分享参数
  252. * title:【主办方名字】 || '' + 用户自定义标题 || 我是第X号大赛代言人!+ 邀请您为《XXX》投票!
  253. */
  254. this.mpShare = {
  255. title: `${this.activitySetting.pullVoteParam.title || title} , 邀请您为《${this.activity.title}》投票!`,
  256. path: '/pages/index/home?path=' + encodePath,
  257. imageUrl: this.activity.imgUrl
  258. }
  259. this.h5share()
  260. },
  261. async h5share() {
  262. // #ifdef H5
  263. /**
  264. * H5分享参数
  265. * title:【主办方名字】 || '' + 用户自定义标题 || 我是第X号大赛代言人!|| 我是普法帮帮代言人!+ 邀请您为《XXX》投票!
  266. */
  267. let shareParam = {
  268. title: `${this.$isNotEmpty(this.activitySetting.pullVoteParam.sponsor) ? `【${this.activitySetting.pullVoteParam.sponsor}】` : ``}${this.posetrParams.title}`,
  269. desc: `邀请您为《${this.activity.title}》投票!`,
  270. imgUrl: this.activity.imgUrl,
  271. link: window.location.origin + window.location.pathname + window.location.hash
  272. }
  273. this.$shareConfig.H5Share(shareParam);
  274. // #endif
  275. },
  276. async getPosetrParamsTitle() {
  277. let title = "我是普法帮帮代言人"
  278. if (this.$isEmpty(this.vuex_phone)) {
  279. return title
  280. }
  281. let params = {
  282. activeId: this.activity.activeId,
  283. phone: this.vuex_phone
  284. }
  285. let res = await this.$api.activity.getPromoteNum(params)
  286. if (this.$isNotEmpty(res.data) && this.$isNotEmpty(res.data.data.index)) {
  287. let index = res.data.data.startIndex
  288. title = `我是第${index}位大赛代言人!`
  289. }
  290. return title
  291. },
  292. handelAuthResult(options) {
  293. if (options.authResult == undefined) {
  294. return
  295. }
  296. this.authResult = JSON.parse(options.authResult)
  297. if (this.authResult.resultCode == '0000') {
  298. //授权成功,直接弹出礼物框
  299. this.hideLoading()
  300. this.showVote()
  301. return
  302. }
  303. // #ifdef MP-WEIXIN
  304. if (this.authResult.resultCode == '9999') {
  305. //授权失败
  306. this.$refs.toast.error(this.authResult.message)
  307. return
  308. }
  309. // #endif
  310. },
  311. handelOrderResult(options) {
  312. if (options.orderPass && this.$cache.get('orderResult')) {
  313. this.orderResult = this.$cache.get('orderResult')
  314. this.createOrder()
  315. }
  316. },
  317. async showVote() {
  318. this.$refs.votePopup.showVote(this.vuex_phone, this.id, this.activity.activeId);
  319. },
  320. init() {
  321. if (this.vuex_phone) {
  322. this.showVote()
  323. }
  324. },
  325. //去投票
  326. toVote(item) {
  327. if (this.$cache.get('orderResult')) {
  328. this.orderResult = this.$cache.get('orderResult')
  329. this.orderResult.goodsId = item.id
  330. this.$cache.put('orderResult', this.orderResult, 1 * 60 * 60)
  331. }
  332. this.selectGoods = item
  333. //移动积分礼物
  334. if(item.payType === 'POINT_EXCHANGE_GOODS'){
  335. if (item.point == 0 ) {
  336. this.getVerificationCode();
  337. this.$refs.verificationCodeAlert.show = true;
  338. //免费投票
  339. // this.freeVote()
  340. return
  341. }
  342. this.$refs.votePopup.hideVote()
  343. //移动积分投票,创建订单
  344. if (this.$cache.get('orderResult')) {
  345. this.createOrder()
  346. return
  347. }
  348. // #ifdef MP-WEIXIN
  349. let params = {
  350. url: 'https://vote.guosen-fumao.cn/order.html',
  351. goodsId: this.selectGoods.id
  352. }
  353. this.$jump('/pages/webview/createOrder' + this.$u.queryParams(params))
  354. // #endif
  355. }else{
  356. // #ifdef H5
  357. if(this.$isEmpty(this.vuex_gzh_userOpenid)){
  358. let code = this.$util.getUrlParam("code");
  359. if(this.$isEmpty(code)){
  360. this.$refs.webAuthAlert.show = true;
  361. }else{
  362. this.getWxUserInfo(code)
  363. console.log("code",code)
  364. }
  365. }else{
  366. this.cashCreateOrder();
  367. }
  368. // #endif
  369. // #ifdef MP-WEIXIN
  370. this.$refs.toast.warn('小程序暂未开放现金投票,请前往H5投票')
  371. this.$refs.votePopup.hideVote();
  372. // #endif
  373. }
  374. },
  375. //移动积分创建订单
  376. async createOrder() {
  377. if (this.$isEmpty(this.orderResult.fingerprint) ||
  378. this.$isEmpty(this.orderResult.sessionId) ||
  379. this.$isEmpty(this.orderResult.goodsId)) {
  380. this.$refs.toast.error('创建订单失败')
  381. return
  382. }
  383. let params = {
  384. fingerprint: this.orderResult.fingerprint,
  385. helpGoodsId: this.orderResult.goodsId,
  386. sessionId: this.orderResult.sessionId,
  387. num: 1,
  388. phone: this.vuex_phone,
  389. userId: this.vuex_userId
  390. }
  391. let res = await this.$api.order.create(params)
  392. if (res.data.success) {
  393. console.log("orderResult", this.orderResult);
  394. this.orderResult.outOrderId = res.data.data
  395. this.orderResult.mobile = this.vuex_phone
  396. this.$refs.smsAlert.showSmsAndSend(this.orderResult)
  397. } else {
  398. this.$refs.toast.error(res.data.msg)
  399. }
  400. },
  401. //获取微信网页授权用户信息
  402. async getWxUserInfo(code) {
  403. let params = {
  404. code: code
  405. }
  406. let res = await this.$api.wxApp.getH5WxUserInfo(params)
  407. if (res.data.success) {
  408. this.$u.vuex('vuex_gzh_userOpenid', res.data.data.openid);
  409. this.cashCreateOrder();
  410. } else {
  411. // if(res.data.code == 400){
  412. // this.$webAuth.getUserOpenid();
  413. // return
  414. // }
  415. this.$refs.toast.error(res.data.msg)
  416. }
  417. },
  418. //现金投票创建订单
  419. async cashCreateOrder() {
  420. let params = {
  421. helpGoodsId: this.selectGoods.id,
  422. num: 1,
  423. phone: this.vuex_phone,
  424. productId: this.id,
  425. userId: this.vuex_userId,
  426. openId: this.vuex_gzh_userOpenid
  427. }
  428. let res = await this.$api.order.cashExchange(params)
  429. if (res.data.success) {
  430. let url = encodeURIComponent(location.href);
  431. let params = {
  432. orderId: res.data.data.bankOrderId,
  433. orderUrl: url,
  434. color: this.vuex_theme.bgColor,
  435. type: 'VOTE_ORDER'
  436. }
  437. this.$api.yeepay.saveOrderUrlAndColor(params)
  438. this.$shareConfig.H5Pay(JSON.parse(res.data.data.prePayTn)).then((res) => {
  439. console.log("作品投票页面res", res)
  440. this.voteSuccess();
  441. },(err) => {
  442. console.log("作品投票页面err", err)
  443. this.$refs.toast.error(err.errMsg)
  444. })
  445. } else {
  446. this.$refs.toast.error(res.data.msg)
  447. }
  448. this.$refs.votePopup.hideVote();
  449. },
  450. //网页授权
  451. webAuthConfirm(){
  452. let url = encodeURIComponent(window.location.href)
  453. this.$webAuth.getUserOpenid(url);
  454. },
  455. async cmccVote(item) {
  456. this.$refs.smsAlert.hideSms()
  457. let params = {
  458. ...item,
  459. machinetype: 'phone',
  460. productId: this.id,
  461. helpGoodsId: this.orderResult.goodsId,
  462. userId: this.vuex_userId,
  463. num: 1,
  464. }
  465. let res = await this.$api.order.exchange(params)
  466. if (res.data.success) {
  467. this.voteSuccess()
  468. this.$refs.smsAlert.hideSms()
  469. } else {
  470. this.$refs.toast.error(res.data.msg)
  471. }
  472. },
  473. voteSuccess() {
  474. try {
  475. let avatar = this.$cache.get('userInfo').avatar || this.defaultAvatar
  476. let activeVote = this.selectGoods.votePointRate
  477. this.$refs.voteSuccess.showSuccess(avatar, activeVote)
  478. } catch (e) {
  479. this.$refs.toast.info('助力成功')
  480. }
  481. },
  482. codeConfirm(code){
  483. this.freeVote(code)
  484. },
  485. //获取验证码
  486. async getVerificationCode() {
  487. let params = {
  488. helpGoodsId: this.selectGoods.id,
  489. productId: this.activity.id,
  490. userId: this.vuex_userId
  491. }
  492. let res = await this.$api.order.verificationCode(params)
  493. if (res.data.success) {
  494. this.verificationCodeImg = res.data.data
  495. }
  496. },
  497. async freeVote(code) {
  498. let params = {
  499. helpGoodsId: this.selectGoods.id,
  500. userId: this.vuex_userId,
  501. num: 1,
  502. productId: this.activity.id,
  503. }
  504. if(this.selectGoods.point == 0){params.code = code;}
  505. let res = await this.$api.order.exchange(params)
  506. if (res.data.success) {
  507. this.$refs.votePopup.hideVote()
  508. this.$refs.verificationCodeAlert.show = false;
  509. this.$refs.verificationCodeAlert.codevalue = '';
  510. this.fetchData()
  511. let avatar = this.$cache.get('userInfo').avatar
  512. let voteCount = this.selectGoods.votePointRate
  513. let pointNum = this.vuex_active_setting.voteAndPointRate
  514. setTimeout(() => {
  515. this.voteSuccess()
  516. }, 200)
  517. } else {
  518. this.$u.toast(res.data.msg)
  519. this.$refs.verificationCodeAlert.codevalue = '';
  520. setTimeout(() => {
  521. this.getVerificationCode();
  522. }, 1000)
  523. }
  524. },
  525. customBack() {
  526. if (this.isCustomBack == true) {
  527. uni.switchTab({
  528. url: '/pages/index/home'
  529. })
  530. } else {
  531. uni.navigateBack({
  532. delta: 1
  533. })
  534. }
  535. },
  536. //分享
  537. showPoster() {
  538. this.$refs.poster.showCanvas()
  539. },
  540. async shareConfirm(item) {
  541. if (item.name == '海报') {
  542. this.showPoster()
  543. return
  544. }
  545. if (item.name == '好友') {
  546. // #ifdef H5
  547. this.$refs.timelinePopup.PopupTyPe = 'friend';
  548. this.$refs.timelinePopup.show()
  549. // #endif
  550. return
  551. }
  552. if (item.name == '朋友圈') {
  553. this.$refs.timelinePopup.PopupTyPe = 'friendsCircle';
  554. this.$refs.timelinePopup.show()
  555. }
  556. },
  557. async showShare() {
  558. await this.handelShareParams()
  559. this.$refs.sharePopup.show()
  560. },
  561. skipShop() {
  562. uni.setStorageSync('isWorksSkip', true)
  563. uni.switchTab({
  564. url: '/pages/shop/shop'
  565. })
  566. },
  567. // h5 创建订单 begin
  568. h5CreateOrder() {
  569. if (this.$cache.get('orderResult')) {
  570. this.orderResult = this.$cache.get('orderResult')
  571. return
  572. }
  573. //初始化js脚本
  574. this.initScript()
  575. //获取Fmopt
  576. this.fetchFmopt()
  577. //获取sessionId
  578. this.loadScriptFunc("", this.fetchSessionId())
  579. //打印数据
  580. this.cacheOrderData()
  581. },
  582. cacheOrderData() {
  583. let _this = this
  584. setTimeout(() => {
  585. _this.$nextTick(function() {
  586. try {
  587. _this.count++
  588. console.log("sessionId:" + window.sessionId);
  589. console.log("fingerprint:" + _fmOpt.getinfo());
  590. console.log("获取成功啦");
  591. _this.pushInCache(_fmOpt.getinfo(), window.sessionId)
  592. } catch (e) {
  593. console.log(_this.count);
  594. if (_this.count < 10) {
  595. _this.cacheOrderData()
  596. }
  597. }
  598. })
  599. }, 20)
  600. },
  601. pushInCache(fingerprint, sessionId) {
  602. this.orderResult = {
  603. fingerprint: encodeURIComponent(fingerprint),
  604. sessionId,
  605. goodsId: this.selectGoods.id
  606. }
  607. this.$cache.put('orderResult', this.orderResult)
  608. },
  609. initScript() {
  610. let monitorURL = "https://static.tongdun.net/monitor/monitor.js"
  611. this.loadScript(monitorURL)
  612. let tfdURL = "https://j.changyoyo.com/static/js/common/tfd.js"
  613. this.loadScript(tfdURL)
  614. let jqueryURL = "https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js"
  615. this.loadScript(jqueryURL)
  616. },
  617. fetchFmopt() {
  618. window._fmOpt = {
  619. partner: 'changyou',
  620. appName: 'changyou_web',
  621. token: 'changyou' + "-" + new Date().getTime() + "-" +
  622. Math.random().toString(16).substr(2),
  623. fmb: true,
  624. success: function(data) {
  625. console.log('blackbox: ', data)
  626. },
  627. fpHost: "https://fp.tongdun.net"
  628. };
  629. var cimg = new Image(1, 1);
  630. cimg.onload = function() {
  631. _fmOpt.imgLoaded = true;
  632. };
  633. cimg.src =
  634. "https://fp.tongdun.net/fp/clear.png?partnerCode=changyou&appName=changyou_web&tokenId=" +
  635. _fmOpt.token;
  636. var fm = document.createElement('script');
  637. fm.type = 'text/javascript';
  638. fm.async = true;
  639. fm.src = ('https:' == document.location.protocol ? 'https://' : 'http://') +
  640. 'static.tongdun.net/v3/fm.js?ver=0.1&t=' + (new Date().getTime() / 3600000).toFixed(0);
  641. var s = document.getElementsByTagName('script')[0];
  642. s.parentNode.insertBefore(fm,
  643. s);
  644. },
  645. loadScript(src) {
  646. var script = document.createElement('script');
  647. script.src = src;
  648. document.body.appendChild(script);
  649. },
  650. loadScriptFunc(url, callback) {
  651. callback = typeof callback === 'function' ? callback : function() {};
  652. var head = document.getElementsByTagName('head')[0];
  653. var script = document.createElement('script');
  654. script.type = 'text/javascript';
  655. script.src = url;
  656. script.onreadystatechange = function() {
  657. if (this.readyState == "loaded" || this.readyState == "complete") {
  658. callback();
  659. }
  660. }
  661. script.onload = callback;
  662. head.appendChild(script);
  663. },
  664. fetchSessionId() {
  665. var url, ts, sessionId, appId, appkey;
  666. url = "tfd.changyoyo.com";
  667. appId = "5308e20b";
  668. appkey = "3daf27ea2fe840ada6af8e1ec0d7b760";
  669. ts = new Date().getTime();
  670. sessionId = "changyo-pc-" + ts + "-" + Math.random().toString(16).substr(2);
  671. window.sessionId = sessionId;
  672. [document.getElementsByTagName('script')[0].parentNode.appendChild(document.createElement('script')).src =
  673. "http://" +
  674. url + "/did/js/dp.js?appId=" + appId + "&appkey=" + appkey + "&sessionId=" + sessionId +
  675. "&ts=" +
  676. ts
  677. ][0];
  678. },
  679. //h5 创建订单end
  680. //获取活动参数
  681. async getActivitySetting() {
  682. // if (this.$isNotEmpty(this.vuex_active_setting)) { //有缓存直接从缓存获取
  683. // this.activitySetting = this.vuex_active_setting;
  684. // return;
  685. // }
  686. let params = {
  687. activeId: this.activity.activeId,
  688. platformSettingEnum: 'ACTIVE_SETTING'
  689. }
  690. let activeSetting = JSON.parse((await this.$api.platform.getPlatformValue(params)).data.data);
  691. this.$config.setTheme(activeSetting.theme, this);
  692. this.customStyle.background = this.vuex_theme.bgColor;
  693. this.activitySetting = activeSetting;
  694. activeSetting.defaultActiveId = this.activity.activeId
  695. this.$u.vuex('vuex_active_setting', activeSetting);
  696. },
  697. },
  698. }
  699. </script>
  700. <style lang="scss" scoped>
  701. .works-video {
  702. width: 100vw;
  703. height: 422rpx;
  704. }
  705. .title {
  706. padding: 20rpx;
  707. .work-no {
  708. padding: 5rpx 10rpx 5rpx 10rpx;
  709. border-radius: 7rpx;
  710. }
  711. .work-title {
  712. padding: 0 0 0 20rpx;
  713. color: #353535;
  714. font-size: 32rpx;
  715. font-weight: 800;
  716. }
  717. }
  718. .work-info-box {
  719. padding: 30rpx 0 15rpx 10rpx;
  720. .remen-icon {
  721. width: 30rpx;
  722. height: 30rpx;
  723. }
  724. .vote-count {
  725. padding: 0 20rpx 0 10rpx;
  726. font-size: 40rpx;
  727. color: #353535;
  728. font-weight: 800;
  729. }
  730. .work-rank {
  731. margin-left: -10rpx;
  732. color: #353535;
  733. background: #FDEBEC;
  734. border-radius: 21px 21px 21px 21px;
  735. font-size: 22rpx;
  736. padding: 8rpx 15rpx 8rpx 15rpx;
  737. }
  738. }
  739. .footer-bar {
  740. position: fixed;
  741. bottom: 0;
  742. left: 0;
  743. width: 100%;
  744. height: 170rpx;
  745. background-color: white;
  746. }
  747. .canvas-hide {
  748. position: fixed;
  749. right: 100vw;
  750. bottom: 100vh;
  751. z-index: -9999;
  752. opacity: 0;
  753. }
  754. </style>