authorBoost.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546
  1. <template>
  2. <view>
  3. <swiper @change="swiperChange" class="screen-swiper square-dot" style="height: 500upx;" :indicator-dots="isIndicator" :circular="true"
  4. interval="5000" duration="500">
  5. <swiper-item v-if="!$u.test.isEmpty(boostDetail.video)">
  6. <video :autoplay="true"
  7. @play="playVideo"
  8. @ended="ended"
  9. :src="boostDetail.video"
  10. objectFit="fill"></video>
  11. </swiper-item>
  12. <swiper-item>
  13. <view v-if="!$u.test.isEmpty(boostDetail.cover)" @click="preViewImg(boostDetail.cover)" class="bg-img" style="height: 500upx;" :style="{'backgroundImage':'url('+ boostDetail.cover +')'}"></view>
  14. <view v-else class="bg-img" style="height: 500upx;background-image: url('https://music.nanyue6688.com/obsfile/ea1a9741a5d5469e967dac8e8e7f0c9d-singerBg.png');"></view>
  15. </swiper-item>
  16. </swiper>
  17. <view class="homeBtn" @click="home">
  18. <image src="/static/home.png" style="width: 40upx;height: 40upx;" />
  19. </view>
  20. <view class="head">
  21. <view class="title margin-top-sm">{{boostDetail.nickName}}与你分享</view>
  22. <view class="flex justify-between align-center padding-lr">
  23. <view class="flex align-center">
  24. <u-avatar :src="boostDetail.avatar" size="120"></u-avatar>
  25. <view class="padding-left">
  26. <view class="number">{{+boostDetail.hotValue}}</view>
  27. <view class="tag">
  28. <image src="/static/crown.png" style="width: 22upx;height: 19upx;margin-right: 10upx;">
  29. </image>
  30. <view class="text-sm text-white">热力榜第{{boostDetail.sequence}}</view>
  31. </view>
  32. </view>
  33. </view>
  34. <view class="text-center">
  35. <button class="cu-btn round theme-bg-color text-white text-bold" @click="userBoost">
  36. <text>热力值</text>
  37. <text class="cuIcon-hot padding-lr-xs"></text>
  38. <text>X{{boostDetail.activityHotValue}}</text>
  39. </button>
  40. <view class="text-sm text-gray margin-top-xs">今日可助力次数: {{boostDetail.allowHitCount}}</view>
  41. </view>
  42. </view>
  43. </view>
  44. <view class="flex justify-between align-center bg-white" style="padding: 40upx 30upx 30upx 30upx;">
  45. <view class="flex align-center">
  46. <image src="/static/icon-person.png" style="width: 82upx;height: 82upx;"></image>
  47. <view class="padding-left-sm">
  48. <view class="text-lg text-bold text-black">好的音乐值得分享</view>
  49. <view class="text-sm text-gray padding-top-xs">邀请好友分享,获得热力值更快哦</view>
  50. </view>
  51. </view>
  52. <button style="height: 56upx;" class="cu-btn round theme-bg-color text-white text-sm"
  53. @click="invite">去分享</button>
  54. </view>
  55. <view class="container">
  56. <view class="title">分享音乐,公益同行</view>
  57. </view>
  58. <view class="bg-white padding-sm">
  59. <view class="grid col-3 padding-xs">
  60. <block v-for="(item,index) in boostDetail.presentList" :key="index">
  61. <view class="text-center padding-top-xs" :class="current == index ? 'boder':''"
  62. @click="change(item.id,index)">
  63. <image :src="item.icon" style="width: 150upx;height: 150upx;"></image>
  64. <view class="margin-tb-xs">金额: {{+item.price}}</view>
  65. <view class="margin-bottom-xs" style="font-size: 22rpx;">
  66. <text>公益捐赠</text>
  67. <text class="text-bold">{{+item.pointsValue}}</text>
  68. <text>积分</text>
  69. </view>
  70. <view style="margin-bottom: 10upx;">
  71. <text class="cuIcon-hotfill theme-color"></text>
  72. <text class="text-sm">{{+item.hotValue}}热力值/{{+item.pointsValue}}</text>
  73. </view>
  74. </view>
  75. </block>
  76. </view>
  77. </view>
  78. <view class="bg-white padding-sm">
  79. <view class="text-sm text-gray">50%的收入由平台发起定向公益捐赠</view>
  80. <view class="text-sm text-gray">50%的积分可捐赠或兑换商品</view>
  81. </view>
  82. <view style="height: 100upx;"></view>
  83. <view class="footer-fixed bg-white padding-sm flex justify-between align-center">
  84. <view>
  85. <text style="font-size: 36upx;color: #FF4200">¥</text>
  86. <text
  87. style="font-size: 46upx;font-family: PingFang SC;font-weight: bold;color: #FF4200">{{count * currentPresentSum}}</text>
  88. </view>
  89. <view class="flex align-center">
  90. <view class="flex align-center">
  91. <view class="padding-right-sm" @click="minus">
  92. <u-icon name="minus-circle-fill" color="#5a3ee8" size="36"></u-icon>
  93. </view>
  94. <input type="number" class="text-center input" v-model="count" />
  95. <view class="padding-left-sm" @click="plus">
  96. <u-icon name="plus-circle-fill" color="#5a3ee8" size="36"></u-icon>
  97. </view>
  98. </view>
  99. <button style="width: 150upx;" class="margin-left cu-btn round theme-bg-color text-white text-sm"
  100. @click="presentBoost(boostDetail.presentList[current].id)">分享</button>
  101. </view>
  102. </view>
  103. <u-popup v-model="shareShow" mode="bottom" height="460rpx" border-radius="30">
  104. <view class="flex align-center justify-around" style="padding: 90upx 60upx 70upx 60upx;">
  105. <view class="text-center" @click="wxShare">
  106. <image src="/static/wx-share.png" style="width: 125upx;height: 125upx;"></image>
  107. <view class="text-sm">分享好友</view>
  108. </view>
  109. <view class="text-center" @click="pyqShare">
  110. <image src="/static/wx-pyq.png" style="width: 129upx;height: 124upx;"></image>
  111. <view class="text-sm">分享朋友圈</view>
  112. </view>
  113. </view>
  114. <view style="width: 10upx;height: 10upx;" class="qrimg-i" v-if="shareShow">
  115. <tki-qrcode cid="qrcode" ref="qrcode" :val="val" :size="size" :onval="onval" :loadMake="loadMake"
  116. :usingComponents="true" @result="qrR" />
  117. </view>
  118. <view class="padding">
  119. <button class="cu-btn bg-gray round" style="width: 100%;height: 80upx;"
  120. @click="shareShow = false">取消</button>
  121. </view>
  122. </u-popup>
  123. <u-popup v-model="dialogShow" mode="center" width="500rpx" height="600rpx" border-radius="30">
  124. <view class="bg-img text-center"
  125. style="background-image: url('https://upload-file-data.obs.cn-south-1.myhuaweicloud.com/e914f556be414767aca011a30961560a-dialogBgImg.png');height: 600rpx;">
  126. <view style="height: 120upx;"></view>
  127. <u-avatar :src="boostDetail.avatar" size="160"></u-avatar>
  128. <view class="margin-bottom-xs margin-top text-bold">
  129. <text>公益捐赠:{{+boostDetail.presentList[current].pointsValue * count}}积分</text>
  130. </view>
  131. <view class="margin-bottom-xs"
  132. style="font-size: 24upx;font-family: PingFang SC;font-weight: bold;color: #323035;">
  133. 你将为{{boostDetail.nickName}}增加{{+boostDetail.presentList[current].hotValue * count}}热力值</view>
  134. <view class="text-gray text-sm" v-if="presentDetail.isGiveMedal == 1">公益勋章X {{count}}</view>
  135. <view class="text-gray text-sm" v-if="presentDetail.isSendGoods == 1">{{presentDetail.goodsName}} X
  136. {{count}}</view>
  137. <view class="text-gray text-sm">可得{{+boostDetail.presentList[current].pointsValue * count}}积分,用于积分商城兑换
  138. </view>
  139. <view class="padding">
  140. <u-button class="custom-style" shape="circle" @click="pay">去支付</u-button>
  141. </view>
  142. </view>
  143. </u-popup>
  144. <u-popup v-model="successShow" mode="center" width="500rpx" height="600rpx" border-radius="30">
  145. <view class="bg-img text-center"
  146. style="background-image: url('https://upload-file-data.obs.cn-south-1.myhuaweicloud.com/e914f556be414767aca011a30961560a-dialogBgImg.png');height: 600rpx;">
  147. <view style="height: 120upx;"></view>
  148. <u-avatar :src="boostDetail.avatar" size="160"></u-avatar>
  149. <view class="margin-top"
  150. style="font-size: 30upx;font-family: PingFang SC;font-weight: bold;color: #323035;">
  151. 恭喜您已为{{boostDetail.nickName}}注入{{+boostDetail.presentList[current].hotValue * count}}热力值</view>
  152. <view class="margin-tb-xs">{{+boostDetail.presentList[current].pointsValue * count}}积分已到账,用于积分商城兑换
  153. </view>
  154. <view class="text-gray text-sm">购买成功!快去我的订单兑换或捐赠</view>
  155. <view class="padding">
  156. <u-button class="custom-style" shape="circle" @click="successShow = false">确定</u-button>
  157. </view>
  158. </view>
  159. </u-popup>
  160. <u-popup v-model="errorShow" mode="center" width="500rpx" height="600rpx" border-radius="30">
  161. <view class="bg-img text-center"
  162. style="background-image: url('https://upload-file-data.obs.cn-south-1.myhuaweicloud.com/e914f556be414767aca011a30961560a-dialogBgImg.png');height: 600rpx;">
  163. <view style="height: 120upx;"></view>
  164. <u-avatar :src="boostDetail.avatar" size="160"></u-avatar>
  165. <view class="text-center margin-top text-lg text-bold">支付失败</view>
  166. <view class="padding">
  167. <u-button class="custom-style" shape="circle" @click="errorShow = false">确定</u-button>
  168. </view>
  169. </view>
  170. </u-popup>
  171. <u-popup v-model="payShow" mode="center" width="500rpx" height="320rpx" border-radius="30">
  172. <view class="text-center text-lg padding">请确定支付是否已完成</view>
  173. <u-line color="#c2c2c2"></u-line>
  174. <view class="text-red text-center text-lg padding" @click="checkPayInterval">已完成支付</view>
  175. <u-line color="#c2c2c2"></u-line>
  176. <view class="text-gray text-center text-lg padding" @click="pay">支付遇到问题,重新支付</view>
  177. </u-popup>
  178. <view class="cu-modal" :class="wxShareShow ? 'show' : ''" style="z-index: 9999;">
  179. <view class="cu-dialog">
  180. <view style="height:150px;">
  181. <view style="color: #000000;font-size: 38upx;padding: 40upx;">1. 先点击右上角<text class="text-bold"
  182. style="font-size: 38upx;">"···"</text></view>
  183. <view style="color: #000000;font-size: 38upx;padding: 40upx;">2. 选择<text class="text-bold"
  184. style="font-size: 38upx;">"{{type}}"</text></view>
  185. </view>
  186. <view class="cu-bar text-green text-lg bg-white">
  187. <view class="action margin-0 flex-sub solid-left" @tap="wxShareShow = false">知道了</view>
  188. </view>
  189. </view>
  190. </view>
  191. <works-poster ref="myCard" :works="works"></works-poster>
  192. </view>
  193. </template>
  194. <script>
  195. import {
  196. appId
  197. } from '@/common/conf/config.js';
  198. import {
  199. authUrl
  200. } from '@/common/conf/config.js';
  201. import {
  202. getUrlParams
  203. } from '@/common/utils/utils.js';
  204. import worksPoster from "@/components/works-poster/works-poster.vue";
  205. import {
  206. pathToBase64,
  207. base64ToPath
  208. } from '@/common/utils/index.js'
  209. export default {
  210. components: {
  211. worksPoster
  212. },
  213. data() {
  214. return {
  215. isPlay:false,
  216. swiperCurrent:0,
  217. val: '', // 要生成的二维码值
  218. size: 200, // 二维码大小
  219. //unit: 'upx', // 单位
  220. //icon: '', // 二维码图标
  221. //iconsize: 40, // 二维码图标大小
  222. //lv: 3, // 二维码容错级别 , 一般不用设置,默认就行
  223. onval: false, // val值变化时自动重新生成二维码
  224. loadMake: true, // 组件加载完成后自动生成二维码
  225. src: '', // 二维码生成后的图片地址或base64
  226. works: {
  227. image: 'https://music.nanyue6688.com/obsfile/9bd6e4bb9e464794a23d7073de826662-图层 1.png',
  228. title: '',
  229. hotValue: '',
  230. rank: '',
  231. avatar: '',
  232. name: '',
  233. qrcode: 'https://music.nanyue6688.com/obsfile/c531395a576b4b1aa7377cdbf62cb088-default.png',
  234. logo: 'https://music.nanyue6688.com/obsfile/0f1d302bde434a68a049fafdeb5e1209-logo.png'
  235. },
  236. current: 0,
  237. boostDetail: {},
  238. dialogShow: false,
  239. shareShow: false,
  240. wxShareShow: false,
  241. count: 1,
  242. currentPresentSum: 0,
  243. activityId: '',
  244. senderId: '',
  245. receiverId: '',
  246. type: '',
  247. presentId: '',
  248. successShow: false,
  249. presentDetail: {},
  250. errorShow: false,
  251. payShow: false,
  252. orderId: '',
  253. }
  254. },
  255. onLoad(options) {
  256. this.activityId = options.activityId;
  257. this.senderId = uni.getStorageSync("userId");
  258. this.receiverId = options.receiverId;
  259. console.log(this.senderId);
  260. if (!this.$u.test.isEmpty(this.senderId)) {
  261. this.val =
  262. "https://music.nanyue6688.com/vote-h5/index.html#/pages/activityList/activity/authorBoost?activityId=" +
  263. this.activityId + '&receiverId=' + this.receiverId + "&agenterId=" + this.senderId;
  264. } else {
  265. this.val =
  266. "https://music.nanyue6688.com/vote-h5/index.html#/pages/activityList/activity/authorBoost?activityId=" +
  267. this.activityId + '&receiverId=' + this.receiverId;
  268. }
  269. console.log("*********************=>", this.val);
  270. this.getBoostDetail(options.activityId, options.receiverId);
  271. this.authorization();
  272. },
  273. computed:{
  274. isIndicator:{
  275. get(){
  276. if (this.boostDetail.cover && this.boostDetail.video && !this.isPlay) {
  277. return true
  278. }else {
  279. return false
  280. }
  281. }
  282. },
  283. },
  284. methods: {
  285. swiperChange(e){
  286. this.swiperCurrent=e.detail.current
  287. },
  288. playVideo(){
  289. this.isPlay=true
  290. },
  291. ended(){
  292. this.isPlay=false
  293. },
  294. home() {
  295. uni.navigateTo({
  296. url: "/pages/activityList/home/home?activityId=" + this.activityId,
  297. })
  298. },
  299. //打榜助力
  300. userBoost() {
  301. if (this.$u.test.isEmpty(this.senderId)) {
  302. let path = 'pages/activityList/activity/authorBoost?activityId=' + this.activityId + '&receiverId=' +
  303. this.receiverId;
  304. window.location.href = authUrl(path);
  305. } else {
  306. this.$u.api.boost.doHit({
  307. activityId: this.activityId,
  308. senderId: this.senderId,
  309. receiverId: this.receiverId,
  310. type: 2
  311. }).then(res => {
  312. console.log(res);
  313. if (res.code == 400) {
  314. uni.showToast({
  315. icon: "none",
  316. title: res.msg
  317. })
  318. } else {
  319. this.$u.toast('助力成功')
  320. this.getBoostDetail(this.activityId, this.receiverId);
  321. }
  322. })
  323. }
  324. },
  325. //礼物支付
  326. async pay() {
  327. this.payShow = false;
  328. let _this = this;
  329. if (this.$u.test.isEmpty(this.senderId)) {
  330. let path = 'pages/activityList/activity/authorBoost?activityId=' + this.activityId +
  331. '&receiverId=' + this.receiverId;
  332. window.location.href = authUrl(path);
  333. } else {
  334. this.orderId = this.$u.guid(16);
  335. let orderInfo = (await this.$u.api.yeePay.initOrder({
  336. "channel": "ALIPAY",
  337. "goodsName": this.boostDetail.presentList[this.current].name,
  338. "notifyUrl": "1",
  339. "orderAmount": this.count * this.currentPresentSum,
  340. "orderId": this.orderId,
  341. "payWay": "USER_SCAN",
  342. "scene": "OFFLINE",
  343. "userIp": "127.0.0.1"
  344. }));
  345. _this.$u.api.boost.billRecord({
  346. userId: _this.senderId,
  347. orderId: this.orderId,
  348. payPath: encodeURIComponent(window.location.href),
  349. openId: "",
  350. activityId: _this.activityId,
  351. price: _this.count * _this.currentPresentSum,
  352. presentId: _this.boostDetail.presentList[_this.current].id,
  353. presentCount: _this.count,
  354. relationId: _this.receiverId,
  355. type: 2,
  356. payStatus: 0,
  357. }).then(res => {
  358. if (typeof orderInfo.prePayTn != 'undefined') {
  359. //调起支付
  360. this.toPay(orderInfo.prePayTn);
  361. }
  362. })
  363. }
  364. },
  365. //获取助力详情
  366. getBoostDetail(activityId, receiverId) {
  367. this.$u.api.user.boost({
  368. activityId: activityId,
  369. receiverId: receiverId,
  370. senderId: this.senderId
  371. }).then(res => {
  372. this.boostDetail = res;
  373. this.currentPresentSum = res.presentList[this.current].price;
  374. })
  375. },
  376. change(id, index) {
  377. this.presentId = id;
  378. this.currentPresentSum = 0;
  379. this.count = 1;
  380. this.current = index;
  381. this.currentPresentSum = this.boostDetail.presentList[index].price;
  382. },
  383. //礼物+
  384. plus() {
  385. this.count++
  386. },
  387. //礼物 -
  388. minus() {
  389. if (this.count > 1) {
  390. this.count--
  391. }
  392. },
  393. async authorization() {
  394. let agenterId = uni.getStorageSync("agenterId")
  395. let params = getUrlParams(window.location.search);
  396. if (!this.$u.test.isEmpty(params.code)) {
  397. let res = await this.$u.api.wxInfo.getUserInfo({
  398. userCode: params.code
  399. });
  400. uni.setStorageSync("openid", res.openid);
  401. let datas = {
  402. nickName: res.nickname,
  403. avatar: res.headimgurl,
  404. gender: res.sex,
  405. openid: res.openid,
  406. unionid: res.unionid,
  407. province: res.province,
  408. city: res.city
  409. }
  410. if (!this.$u.test.isEmpty(agenterId)) {
  411. datas.agenterId = agenterId
  412. }
  413. let result = await this.$u.api.user.login(datas);
  414. if (result) {
  415. this.senderId = result.id;
  416. uni.setStorageSync("userId", result.id);
  417. this.getBoostDetail(this.activityId, this.receiverId);
  418. }
  419. }
  420. },
  421. qrR(res) {
  422. base64ToPath(res).then(res => {
  423. this.works.qrcode = res;
  424. });
  425. },
  426. //邀请
  427. invite() {
  428. this.shareShow = true;
  429. if (!this.$u.test.isEmpty(this.boostDetail.cover)) {
  430. this.works.image = this.boostDetail.cover;
  431. }
  432. this.works.title = this.boostDetail.nickName;
  433. this.works.hotValue = +this.boostDetail.hotValue;
  434. this.works.rank = this.boostDetail.sequence;
  435. this.works.name = this.boostDetail.nickName;
  436. },
  437. wxShare() {
  438. this.shareShow = false;
  439. this.wxShareShow = true;
  440. this.type = "发送给朋友";
  441. },
  442. pyqShare() {
  443. this.$refs.myCard.showCanvas();
  444. this.shareShow = false;
  445. // this.wxShareShow = true;
  446. // this.type = "分享到朋友圈"
  447. },
  448. toPay(info) {
  449. location.href = `alipays://platformapi/startapp?saId=10000007&clientVersion=3.7.0.0718&qrcode=${info}`;
  450. this.dialogShow = false;
  451. setTimeout(() => {
  452. this.payShow = true;
  453. }, 3000)
  454. },
  455. async checkPayInterval() {
  456. this.payShow = false;
  457. let res = await this.$u.api.boost.billRecordDetail({
  458. orderId: this.orderId
  459. })
  460. if (res && res.payStatus == 1) {
  461. this.successShow = true;
  462. this.getBoostDetail(this.activityId, this.receiverId);
  463. } else {
  464. this.errorShow = true;
  465. }
  466. },
  467. presentBoost(id) {
  468. this.$u.api.boost.presentDetail({
  469. id: id
  470. }).then(res => {
  471. this.presentDetail = res;
  472. this.dialogShow = true;
  473. })
  474. },
  475. preViewImg(url) {
  476. uni.previewImage({
  477. urls: [url]
  478. });
  479. }
  480. }
  481. }
  482. </script>
  483. <style lang="scss" scoped>
  484. .head {
  485. background-color: #ffffff;
  486. margin-top: -26upx;
  487. border-radius: 26upx 26upx 0 0;
  488. .number {
  489. font-size: 38upx;
  490. font-family: PingFang SC;
  491. font-weight: 800;
  492. color: #222222;
  493. }
  494. .tag {
  495. padding: 0 10upx;
  496. line-height: 40upx;
  497. display: flex;
  498. align-items: center;
  499. justify-content: center;
  500. background: linear-gradient(90deg, #7355F4 0%, #573BE5 100%);
  501. margin-top: 8upx;
  502. border-radius: 30upx;
  503. }
  504. }
  505. .title {
  506. line-height: 50px;
  507. padding-left: 30upx;
  508. font-size: 30upx;
  509. font-family: PingFang SC;
  510. font-weight: 800;
  511. color: #201F1F;
  512. }
  513. .container {
  514. background-color: #FFFFFF;
  515. margin-top: 30upx;
  516. }
  517. .boder {
  518. box-shadow: -1upx -1upx 60upx #d8d8d8;
  519. border-radius: 16upx;
  520. }
  521. .input {
  522. width: 80upx;
  523. background-color: #ffffff;
  524. text-align: center;
  525. border: none;
  526. height: 60rpx;
  527. min-height: 1.8rem;
  528. }
  529. .custom-style {
  530. background-color: #5b3ee7;
  531. width: 250upx;
  532. color: #ffffff;
  533. }
  534. </style>