authorBoost.vue 17 KB

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