帧视界壹通告,付费看视频的微信小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

428 lines
9.9 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
  1. <template>
  2. <view class="promotionDetail">
  3. <!--顶部导航栏-->
  4. <navbar leftClick @leftClick="$utils.navigateBack" title="推广详情" />
  5. <!--主页面-->
  6. <view class="frame">
  7. <!--标题-->
  8. <view class="title">
  9. <span>推广基本信息</span>
  10. </view>
  11. <!--基本信息-->
  12. <view style="" class="basicInfo">
  13. <!-- <view class="item">
  14. <view class="label">推广名称</view>
  15. <view class="value">
  16. <uv-input v-model="form.promotionName" placeholder="请输入推广名称" border="bottom" type='number'
  17. clearable></uv-input>
  18. </view>
  19. </view> -->
  20. <view class="item">
  21. <view class="label">推广作品名称</view>
  22. <view class="value">{{item.name}}</view>
  23. </view>
  24. <!-- <view class="item">
  25. <view class="label">价格</view>
  26. <view class="value">{{item.price }}</view>
  27. </view>
  28. <view class="item">
  29. <view class="label">时长</view>
  30. <view class="value">{{item.tuTime}}</view>
  31. </view>
  32. <view class="item">
  33. <view class="label">联系方式</view>
  34. <view class="value">
  35. <uv-input v-model="item.phone" placeholder="请输入联系方式" border="bottom" type='number'
  36. clearable></uv-input>
  37. </view>
  38. </view> -->
  39. <view class="item">
  40. <view class="label">剩余推广时长</view>
  41. <view class="value">{{item.remainingPromotionTime}}</view>
  42. </view>
  43. <!-- <view>推广作品</view>
  44. <view style="width: 30%;height: 300rpx;border-radius: 20rpx;overflow: hidden;">
  45. <image :src="item.image" style="width: 100%;height: 100%;"></image>
  46. </view> -->
  47. </view>
  48. <!-- ActionSheet 操作菜单 -->
  49. <uv-action-sheet ref="actionSheet" :actions="upTopList" title="选择推广时长" @select="select" @close="close"
  50. :closeOnClickAction="false">
  51. </uv-action-sheet>
  52. <!--确认发布弹框-->
  53. <uv-popup ref="popup" mode="center" custom-style="height: 400rpx;">
  54. <view class="content">
  55. <view class="title">
  56. 推广选项
  57. </view>
  58. <!--付费周期-->
  59. <view style="" class="payCycle">
  60. <view>付费周期</view>
  61. <view>{{popupData.day}}</view>
  62. </view>
  63. <!--金额-->
  64. <view style="width:100%;display: flex;justify-content: space-between;align-items: center;">
  65. <view>金额</view>
  66. <view>{{popupData.money}}</view>
  67. </view>
  68. <!--确认推广按钮-->
  69. <view class="confirmBottom">
  70. <button @click="confirmPromotion" class="confirmBtn">
  71. 确认推广
  72. </button>
  73. </view>
  74. </view>
  75. </uv-popup>
  76. <!--支付弹框-->
  77. <confirmationPopup ref="confirmationPopup" title="提示" @confirm="payOrder" confirmText="确认支付">
  78. <view class="confirmationPopup">
  79. <image src="/static/image/publish/pay.png" style="width: 150rpx;height: 150rpx;" mode=""></image>
  80. <view class="info">
  81. 确认支付{{ popupData.money }}可置顶{{ popupData.day }}
  82. </view>
  83. </view>
  84. </confirmationPopup>
  85. <!-- 平台审核弹框 -->
  86. <confirmationPopup ref="confirmationPopupUpload" title="提示" confirmText="确认" @confirm="confirm()">
  87. <view class="confirmationPopup">
  88. <image src="/static/image/publish/upload.png" style="width: 150rpx;height: 150rpx;" mode=""></image>
  89. <view class="info">
  90. 已由平台进行审核时间周期为24小时
  91. </view>
  92. </view>
  93. </confirmationPopup>
  94. </view>
  95. <!--继续推广按钮-->
  96. <button @click="continueToPromotion" class="bottomBtn">
  97. 继续推广
  98. </button>
  99. </view>
  100. </template>
  101. <script>
  102. import dayjs from 'dayjs';
  103. import '../../../../common.css'; // 引入公共 CSS 文件
  104. import confirmationPopup from '@/components/toast/confirmationPopup.vue'
  105. export default {
  106. onLoad(options) {
  107. // if (options.item) {
  108. // let item = JSON.parse(decodeURIComponent(options.item));
  109. // }
  110. console.log(options.id,"opID");
  111. this.item.id = options.id
  112. },
  113. components: {
  114. confirmationPopup
  115. },
  116. data() {
  117. return {
  118. upTopList: [],
  119. payList: [],
  120. payId: null,
  121. item: {
  122. day: 0,
  123. money: 0,
  124. },
  125. popupData: {
  126. day: 0,
  127. money: 0,
  128. },
  129. param: {
  130. type: 'default',
  131. title: '结束后跳转标签页',
  132. message: "推广成功",
  133. url: '/pages/componentsD/tag/tag'
  134. }
  135. };
  136. },
  137. mounted() {
  138. this.getData()
  139. this.indexTopPayList()
  140. },
  141. methods: {
  142. // 获取推广详情数据
  143. getData() {
  144. this.$api('infoGetPromotionDetail', {
  145. id: this.item.id
  146. }, res => {
  147. if (res.code == 200) {
  148. console.log(res.result,"res.result");
  149. this.item = res.result
  150. // 计算推广时间加上置顶时间
  151. const futureTime = dayjs(this.item.createTime).add(this.item.tuTime, "day")
  152. // 获取当前时间
  153. const now = dayjs();
  154. // 计算两个时间之间的差异(毫秒)
  155. const diff = futureTime.diff(now);
  156. // 将毫秒转换为小时和天
  157. const hours = Math.floor(diff / 3600000);
  158. const days = Math.floor(hours / 24);
  159. // 根据时间差显示不同的格式
  160. if (days > 0) {
  161. // 超过24小时
  162. const remainingHours = hours % 24;
  163. console.log(`${days}${remainingHours}小时`);
  164. this.item.remainingPromotionTime = `${days}${remainingHours}小时`
  165. } else {
  166. // 没有超过24小时
  167. console.log(`${hours}小时`);
  168. this.item.remainingPromotionTime = `${hours < 0 ? 0 : hours}小时`
  169. }
  170. }
  171. })
  172. },
  173. // 获取置顶方式
  174. indexTopPayList() {
  175. this.$api('indexTopPayList', res => {
  176. if (res.code == 200) {
  177. for (var i = 0; i < res.result.length; i++) {
  178. this.payList = res.result
  179. this.upTopList.push({
  180. name: '置顶' + res.result[i].day + '天' + res.result[i].money + '元'
  181. })
  182. }
  183. }
  184. })
  185. },
  186. select(e) {
  187. console.log('选中该项:', e);
  188. // 使用正则表达式匹配整数和浮点数
  189. const matches = e.name.match(/(\d+\.?\d*)/g).map(Number);
  190. // 如果匹配到数字,则输出
  191. if (matches && matches.length >= 2) {
  192. // console.log(matches, "matches");
  193. for (var i = 0; i < this.payList.length; i++) {
  194. if (this.payList[i].day == matches[0]) {
  195. this.payId = this.payList[i].id
  196. }
  197. }
  198. // 提取天数和金额
  199. this.popupData.day = matches[0]; // 例如,置顶天数
  200. this.popupData.money = matches[1]; // 例如,金额
  201. this.$refs.actionSheet.close() //关闭弹框
  202. this.$refs.popup.open() //打开另外一个弹框
  203. }
  204. },
  205. // ActionSheet 操作菜单关闭
  206. close() {
  207. this.$refs.actionSheet.close() //关闭弹框
  208. // this.$refs.popup.open() //打开另外一个弹框
  209. },
  210. // 提交平台审核的弹框的确认回调
  211. confirm(e) {
  212. uni.navigateTo({
  213. url: "/pages/index/index"
  214. })
  215. },
  216. // 继续推广按钮
  217. continueToPromotion() {
  218. if (this.item.phone == '' || this.item.phone == null) {
  219. return uni.showToast({
  220. title: '请输入联系电话',
  221. icon: 'none'
  222. })
  223. }
  224. this.$refs.actionSheet.open();
  225. },
  226. // 确认发布弹框
  227. confirmPromotion() {
  228. this.$refs.confirmationPopup.open()
  229. this.$refs.popup.close()
  230. },
  231. // 发起支付
  232. payOrder() {
  233. let self = this
  234. console.log(self.item.id, "self.item.id");
  235. let data = {
  236. id: self.item.id,
  237. dayId: self.payId
  238. }
  239. self.$api('confirmPromotion', data,
  240. res => {
  241. console.log(res,"res");
  242. if (res.code == 200) {
  243. uni.requestPayment({
  244. provider: 'wxpay', // 服务提提供商
  245. timeStamp: res.result.timeStamp, // 时间戳
  246. nonceStr: res.result.nonceStr, // 随机字符串
  247. package: res.result.packageValue,
  248. signType: res.result.signType, // 签名算法
  249. paySign: res.result.paySign, // 签名
  250. success: function(res) {
  251. console.log('支付成功', res);
  252. self.$refs.confirmationPopupUpload.open()
  253. // self.$refs.confirmationPopup.close()
  254. },
  255. fail: function(err) {
  256. console.log('支付失败', err);
  257. self.$refs.confirmationPopup.close()
  258. uni.showToast({
  259. icon: 'none',
  260. title: "支付失败"
  261. })
  262. }
  263. });
  264. }
  265. })
  266. },
  267. }
  268. }
  269. </script>
  270. <style lang="scss" scoped>
  271. * {
  272. box-sizing: border-box;
  273. margin: 0;
  274. padding: 0;
  275. }
  276. .promotionDetail {
  277. width: 100vw;
  278. height: 100vh;
  279. .frame {
  280. width: 100%;
  281. //height: calc(100vh - 220rpx);
  282. padding: 28rpx 28rpx 0 28rpx;
  283. .title {
  284. font-size: 36rpx;
  285. font-weight: 600;
  286. }
  287. .basicInfo {
  288. display: flex;
  289. flex-direction: column;
  290. gap: 60rpx;
  291. margin-top: 50rpx;
  292. width: 90%;
  293. .item {
  294. display: flex;
  295. justify-content: space-between;
  296. .label {
  297. width: 60%;
  298. }
  299. .value {
  300. width: 40%;
  301. text-align: right;
  302. }
  303. }
  304. }
  305. .bottom {
  306. position: fixed;
  307. bottom: 30rpx;
  308. left: 25%;
  309. width: 50%;
  310. height: 100rpx;
  311. .continueBtn {
  312. color: #ffffff;
  313. background: $uni-linear-gradient-btn-color;
  314. }
  315. }
  316. .confirmationPopup {
  317. display: flex;
  318. flex-direction: column;
  319. align-items: center;
  320. justify-content: center;
  321. width: 100%;
  322. height: 300rpx;
  323. image {
  324. margin-top: 40rpx;
  325. }
  326. .info {
  327. margin-top: 40rpx;
  328. font-size: 26rpx;
  329. }
  330. }
  331. }
  332. .content {
  333. display: flex;
  334. flex-direction: column;
  335. justify-content: flex-start;
  336. gap: 20rpx;
  337. width: 600rpx;
  338. height: 100%;
  339. padding: 20rpx;
  340. .title {
  341. display: flex;
  342. justify-content: center;
  343. align-items: center;
  344. }
  345. .payCycle {
  346. width: 100%;
  347. display: flex;
  348. justify-content: space-between;
  349. align-items: center;
  350. }
  351. .confirmBtn {
  352. width: 50%;
  353. height: 80rpx;
  354. text-align: center;
  355. color: #ffffff;
  356. background: linear-gradient(to right, #3c69f1, #5f3bf5);
  357. display: flex;
  358. justify-content: center;
  359. align-items: center;
  360. font-size: 30rpx;
  361. margin-top: 50rpx;
  362. }
  363. }
  364. }
  365. /deep/ .uv-popup .uv-popup__content {
  366. border-radius: 20rpx;
  367. }
  368. </style>