authorBoost.vue 16 KB

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