musicBoost.vue 17 KB

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