authorBoost.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  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="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">成功邀请一位好友打榜,热力值+5</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="flex justify-around">
  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: 80upx;height: 80upx;"></image>
  49. <view class="text-sm margin-tb-xs">金额: {{+item.price}}</view>
  50. <view style="margin-bottom: 10upx;">
  51. <text class="cuIcon-hotfill theme-color"></text>
  52. <text style="font-size: 20upx;">{{+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 class="padding">
  88. <button class="cu-btn bg-gray round" style="width: 100%;height: 80upx;" @click="shareShow = false">取消</button>
  89. </view>
  90. </u-popup>
  91. <u-popup v-model="dialogShow" mode="center" width="500rpx" height="600rpx" border-radius="30">
  92. <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;">
  93. <view style="height: 120upx;"></view>
  94. <u-avatar src="/static/avatar.png" size="160"></u-avatar>
  95. <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>
  96. <view class="text-gray text-sm" v-if="presentDetail.isGiveMedal == 1">公益勋章X {{count}}</view>
  97. <view class="text-gray text-sm" v-if="presentDetail.isSendGoods == 1">{{presentDetail.goodsName}} X {{count}}</view>
  98. <view class="text-gray text-sm">可得{{+boostDetail.presentList[current].pointsValue * count}}积分,可用于国信商城兑换</view>
  99. <view class="padding">
  100. <u-button class="custom-style" shape="circle" @click="pay">去支付</u-button>
  101. </view>
  102. </view>
  103. </u-popup>
  104. <u-popup v-model="successShow" 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="/static/avatar.png" size="160"></u-avatar>
  108. <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>
  109. <view class="margin-tb-xs">{{+boostDetail.presentList[current].pointsValue * count}}已到账,可用于商城兑换消费</view>
  110. <view class="text-gray text-sm">购买成功!快去我的订单兑换或捐赠</view>
  111. <view class="padding">
  112. <u-button class="custom-style" shape="circle" @click="successShow = false">确定</u-button>
  113. </view>
  114. </view>
  115. </u-popup>
  116. <view class="cu-modal" :class="wxShareShow ? 'show' : ''" style="z-index: 9999;">
  117. <view class="cu-dialog">
  118. <view style="height:150px;">
  119. <view style="color: #000000;font-size: 38upx;padding: 40upx;">1. 先点击右上角<text class="text-bold" style="font-size: 38upx;">"···"</text></view>
  120. <view style="color: #000000;font-size: 38upx;padding: 40upx;">2. 选择<text class="text-bold" style="font-size: 38upx;">"{{type}}"</text></view>
  121. </view>
  122. <view class="cu-bar text-green text-lg bg-white">
  123. <view class="action margin-0 flex-sub solid-left" @tap="wxShareShow = false">知道了</view>
  124. </view>
  125. </view>
  126. </view>
  127. </view>
  128. </template>
  129. <script>
  130. import {appId} from '@/common/conf/config.js';
  131. import {authUrl} from '@/common/conf/config.js';
  132. import {getUrlParams} from '@/common/utils/utils.js';
  133. export default {
  134. data() {
  135. return {
  136. current: 0,
  137. boostDetail: {},
  138. dialogShow: false,
  139. shareShow: false,
  140. wxShareShow: false,
  141. count: 1,
  142. currentPresentSum: 0,
  143. activityId: '',
  144. senderId: '',
  145. receiverId: '',
  146. type: '',
  147. presentId:'',
  148. successShow: false,
  149. presentDetail: {},
  150. }
  151. },
  152. onLoad(options) {
  153. this.activityId = options.activityId;
  154. this.senderId = uni.getStorageSync("userId");
  155. this.receiverId = options.receiverId;
  156. this.getBoostDetail(options.activityId, options.receiverId);
  157. this.authorization();
  158. },
  159. methods: {
  160. //打榜助力
  161. userBoost() {
  162. if (this.$u.test.isEmpty(this.senderId)) {
  163. let path = 'pages/activityList/activity/authorBoost?activityId=' + this.activityId + '&receiverId=' + this.receiverId;
  164. window.location.href = authUrl(path);
  165. } else {
  166. this.$u.api.boost.doHit({activityId: this.activityId, senderId: this.senderId, receiverId: this.receiverId, type: 2}).then(res => {
  167. console.log(res);
  168. if (res.code == 400) {
  169. uni.showToast({
  170. icon: "none",
  171. title: res.msg
  172. })
  173. } else {
  174. this.getBoostDetail(this.activityId, this.receiverId);
  175. }
  176. })
  177. }
  178. },
  179. //礼物支付
  180. async pay() {
  181. if (this.$u.test.isEmpty(this.senderId)) {
  182. let path = 'pages/activityList/activity/authorBoost?activityId=' + this.activityId + '&receiverId=' + this.receiverId;
  183. window.location.href = authUrl(path);
  184. } else {
  185. let orderInfo = (await this.$u.api.yeePay.initOrder(
  186. {
  187. "appId": appId,
  188. "channel": "WECHAT",
  189. "channelPromotionInfo": "",
  190. "channelSpecifiedInfo": "",
  191. "csUrl": "",
  192. "expiredTime": "",
  193. "fundProcessType": "",
  194. "goodsName": this.boostDetail.presentList[this.current].name,
  195. "memo": "",
  196. "notifyUrl": "https://yyzs.nanyue6688.com/vote-h5/index.html",
  197. "orderAmount": this.count * this.currentPresentSum,
  198. "orderId": new Date().getTime(),
  199. "payWay": "WECHAT_OFFIACCOUNT",
  200. "redirectUrl": "",
  201. "scene": "OFFLINE",
  202. "uniqueOrderNo": "",
  203. "userId": uni.getStorageSync("openid"),
  204. "userIp": "127.0.0.1"
  205. }
  206. ));
  207. if(typeof orderInfo.prePayTn != 'undefined' ){
  208. //调起支付
  209. this.toPay(JSON.parse(orderInfo.prePayTn));
  210. }
  211. }
  212. },
  213. //获取助力详情
  214. getBoostDetail(activityId, receiverId) {
  215. this.$u.api.user.boost({activityId: activityId, receiverId: receiverId, senderId: this.senderId}).then(res => {
  216. this.boostDetail = res;
  217. this.currentPresentSum = res.presentList[this.current].price;
  218. })
  219. },
  220. change(id,index) {
  221. this.presentId = id;
  222. this.currentPresentSum = 0;
  223. this.count = 1;
  224. this.current = index;
  225. this.currentPresentSum = this.boostDetail.presentList[index].price;
  226. },
  227. //礼物+
  228. plus() {
  229. this.count++
  230. },
  231. //礼物 -
  232. minus() {
  233. if (this.count > 1) {
  234. this.count--
  235. }
  236. },
  237. async authorization() {
  238. let agenterId=uni.getStorageSync("agenterId")
  239. let params = getUrlParams(window.location.search);
  240. if (!this.$u.test.isEmpty(params.code)) {
  241. let res = await this.$u.api.wxInfo.getUserInfo({userCode: params.code});
  242. uni.setStorageSync("openid", res.openid);
  243. let datas = {
  244. nickName: res.nickname,
  245. avatar: res.headimgurl,
  246. gender: res.sex,
  247. openid: res.openid,
  248. unionid: res.unionid,
  249. province:res.province,
  250. city:res.city
  251. }
  252. if (!this.$u.test.isEmpty(agenterId)) {
  253. datas.agenterId=agenterId
  254. }
  255. let result = await this.$u.api.user.login(datas);
  256. if (result) {
  257. this.senderId = result.id;
  258. uni.setStorageSync("userId", result.id);
  259. this.getBoostDetail(this.activityId, this.receiverId);
  260. }
  261. }
  262. },
  263. //邀请
  264. invite() {
  265. this.shareShow = true;
  266. },
  267. wxShare() {
  268. this.shareShow = false;
  269. this.wxShareShow = true;
  270. this.type = "发送给朋友";
  271. },
  272. pyqShare() {
  273. this.shareShow = false;
  274. this.wxShareShow = true;
  275. this.type = "分享到朋友圈"
  276. },
  277. toPay(info) {
  278. console.log(info,456789);
  279. WeixinJSBridge.invoke('getBrandWCPayRequest', info, (res) => {
  280. if (res.err_msg == "get_brand_wcpay_request:ok" ) {
  281. this.$u.api.boost.billRecord({
  282. userId: this.senderId,
  283. openId: uni.getStorageSync("openid"),
  284. activityId: this.activityId,
  285. price: this.count * this.currentPresentSum,
  286. presentId: this.presentId,
  287. presentCount: this.count,
  288. relationId: this.receiverId,
  289. type: 2,
  290. payStatus: 1,
  291. }).then(res => {
  292. this.$u.api.boost.doReward({
  293. activityId: this.activityId,
  294. presentId: this.presentId,
  295. senderId: this.senderId,
  296. receiverId: this.receiverId,
  297. type: 3,
  298. count: this.count,
  299. }).then(res => {
  300. this.successShow = true;
  301. })
  302. })
  303. } else if (res.err_msg == "get_brand_wcpay_request:cancel") {
  304. this.$u.api.boost.billRecord({
  305. userId: this.senderId,
  306. openId: uni.getStorageSync("openid"),
  307. activityId: this.activityId,
  308. price: this.count * this.currentPresentSum,
  309. presentId: this.presentId,
  310. presentCount: this.count,
  311. type: 2,
  312. payStatus: 2,
  313. })
  314. } else {
  315. console.log(res.err_msg);
  316. }
  317. });
  318. },
  319. presentBoost(id) {
  320. this.$u.api.boost.presentDetail({id: id}).then(res => {
  321. this.presentDetail = res;
  322. this.dialogShow = true;
  323. })
  324. }
  325. }
  326. }
  327. </script>
  328. <style lang="scss" scoped>
  329. .head {
  330. background-color: #ffffff;
  331. margin-top: -26upx;
  332. border-radius: 26upx 26upx 0 0;
  333. .number {
  334. font-size: 38upx;
  335. font-family: PingFang SC;
  336. font-weight: 800;
  337. color: #222222;
  338. }
  339. .tag {
  340. padding: 0 10upx;
  341. line-height: 40upx;
  342. display: flex;
  343. align-items: center;
  344. justify-content: center;
  345. background: linear-gradient(90deg, #7355F4 0%, #573BE5 100%);
  346. margin-top: 8upx;
  347. border-radius: 30upx;
  348. }
  349. }
  350. .title {
  351. line-height: 50px;
  352. padding-left: 30upx;
  353. font-size: 30upx;
  354. font-family: PingFang SC;
  355. font-weight: 800;
  356. color: #201F1F;
  357. }
  358. .container {
  359. background-color: #FFFFFF;
  360. margin-top: 30upx;
  361. }
  362. .boder {
  363. box-shadow: -1upx -1upx 60upx #d8d8d8;
  364. border-radius: 16upx;
  365. }
  366. .input {
  367. width: 80upx;
  368. background-color: #ffffff;
  369. text-align: center;
  370. border: none;
  371. height: 60rpx;
  372. min-height: 1.8rem;
  373. }
  374. .custom-style {
  375. background-color: #5b3ee7;
  376. width: 250upx;
  377. color: #ffffff;
  378. }
  379. </style>