details.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505
  1. <template>
  2. <view>
  3. <view>
  4. <image style="width: 100%;height:350rpx;" :src="form.url" mode="scaleToFill"></image>
  5. </view>
  6. <view class="time-crad">
  7. <view class="time-head">
  8. <view class="time-title">
  9. 活动时间
  10. </view>
  11. <view class="time-content">
  12. <view class="time-text">
  13. 开始
  14. <view class="time-text2" style="margin-right: 12rpx;">
  15. {{form.startDate?form.startDate.slice(0,10):''}}
  16. </view>
  17. </view>
  18. <image style="width:50rpx;height:8rpx;" src="/static/images/tabBar/1258.png" mode="scaleToFill">
  19. </image>
  20. <view class="time-text" style="margin-left: 20rpx;">
  21. 结束
  22. <view class="time-text2">
  23. {{form.endDate?form.endDate.slice(0,10):''}}
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. <view class="time-foot">
  29. <view class="time-text">
  30. 距离活动结束还剩
  31. </view>
  32. <uni-countdown :font-size="32" :day="days" :hour="hours" :minute="minutes" :second="seconds"
  33. color="#FFFFFF" background-color="#E75F37" />
  34. </view>
  35. </view>
  36. <!-- <scroll-view scroll-y="true" style="max-height: 28vh;">
  37. </scroll-view>-->
  38. <view style="padding-bottom: 290rpx;">
  39. <view class="card" v-for="(item,index) in form.activityItemsList" :key="index">
  40. <view style="margin-left: 20rpx;">
  41. <u-checkbox-group v-model="item.select" placement="column" @change="rowSelect($event,item)"
  42. :size='15'>
  43. <u-checkbox activeColor="#E75F37" shape="circle" :customStyle="{marginBottom: '8px'}" label="选择"
  44. :name="true" labelSize="28rpx" labelColor='#3B3B3B'></u-checkbox>
  45. </u-checkbox-group>
  46. </view>
  47. <view style="background: #FCF7F5;padding:40rpx 20rpx;border-radius: 10rpx;">
  48. <view style="display: flex;align-items: center;">
  49. <view style="width: 120rpx;height: 120rpx;">
  50. <image :src="item.url"
  51. style="width: 120rpx;height: 120rpx;border-radius: 20rpx;border: 2rpx solid #EEEEEE;">
  52. </image>
  53. </view>
  54. <view style="width: 100%;display: flex;margin-left: 8rpx;">
  55. <view>
  56. <u--text :text="item.cname" size="24rpx" color='#797979' lines="1"></u--text>
  57. <view style="color: #E75F37;font-size: 32rpx;">特价:¥{{item.priceOne}}</view>
  58. <view style="color: #797979;font-size: 24rpx;">原价:¥{{item.priceOnePrimary}}</view>
  59. </view>
  60. <view style="display: flex;justify-content: space-between;margin-top: 20rpx;">
  61. <view>
  62. <u-number-box v-model="item.purchaseQuantity" :min="item.minQuantity"
  63. :max="item.maxQuantity" buttonSize="53rpx" color="#414141" bgColor="#FCF7F5"
  64. iconStyle="color:#A4A4A4" @change="rowNumber($event,item)"></u-number-box>
  65. </view>
  66. </view>
  67. </view>
  68. </view>
  69. </view>
  70. </view>
  71. </view>
  72. <view class="submitBar">
  73. <view style="margin:20rpx 47rpx;">
  74. <view
  75. style="display: flex;justify-content: space-between;align-items: flex-end;padding: 28rpx 0 28rpx 28rpx;">
  76. <u-checkbox-group v-model="selectAll" placement="column" @change="selectAllChange" :size='15'>
  77. <u-checkbox label="全选" name="全选" activeColor="#E75F37" shape="circle" labelSize="28rpx"
  78. labelColor='#3B3B3B'></u-checkbox>
  79. </u-checkbox-group>
  80. <view style="font-size: 24rpx;">合计:<text style="color: #E75F37;">¥</text><text
  81. style="font-size: 42rpx;color: #E75F37;">{{numMoney}}</text></view>
  82. </view>
  83. <view style="height: 2rpx;width: 100%;background: #EEEEEE;">
  84. </view>
  85. <view
  86. style="display: flex;justify-content:space-between;align-items: center;padding: 28rpx 0 28rpx 28rpx;">
  87. <view style="font-size: 24rpx;">
  88. <view style="color:#A3A3A3">共计:<text style="color: #E75F37;">{{numStrip}}条</text></view>
  89. </view>
  90. <view style="display: flex;">
  91. <view v-if='new Date().getTime()<new Date(form.startDate).getTime()' class="left-btn">
  92. 活动未开始
  93. </view>
  94. <view v-else-if='new Date().getTime()>new Date(form.startDate).getTime()&&new Date().getTime()<new Date(form.endDate).getTime()' class="right-btn" @click.stop="immediatePayment('W06')">立即支付
  95. </view>
  96. <view v-else class="left-btn">
  97. 活动已结束
  98. </view>
  99. </view>
  100. </view>
  101. <view style="height: 2rpx;width: 100%;background: #EEEEEE;">
  102. </view>
  103. </view>
  104. </view>
  105. </view>
  106. </template>
  107. <script>
  108. import {
  109. activityDetail,
  110. activityGenerateOrder
  111. } from '@/api/tabBar/activity.js'
  112. import {
  113. getCorpsAddr,
  114. paramserviceDetail
  115. } from '@/api/tabBar/shoppingCart.js'
  116. import {
  117. userDept,
  118. } from '@/api/tabBar/home.js'
  119. export default {
  120. data() {
  121. return {
  122. form: {},
  123. selectAll: [null], // 全选参数
  124. numStrip: 0, // 总条
  125. numMoney: 0, // 总钱
  126. addres: {}, // 地址
  127. corporateName: '', // 公司名称
  128. days: 0,
  129. hours: 0,
  130. minutes: 0,
  131. seconds: 0,
  132. }
  133. },
  134. onLoad(value) {
  135. console.log(value);
  136. this.activityDetailfun(value.id)
  137. // 获取地址
  138. getCorpsAddr().then(res => {
  139. this.addres = res.data
  140. })
  141. //获取公司名称
  142. userDept().then(res => {
  143. this.corporateName = res.data.fullName
  144. })
  145. },
  146. methods: {
  147. // 立即支付
  148. immediatePayment(payType) {
  149. if (this.numStrip == 0) {
  150. uni.showToast({
  151. title: "请选择支付的商品",
  152. icon: 'none'
  153. });
  154. return
  155. }
  156. let arr = []
  157. for (let item of this.form.activityItemsList) {
  158. if (item.select[0]) {
  159. item.goodsNum = item.purchaseQuantity
  160. item.price = item.priceOne
  161. arr.push(item)
  162. }
  163. }
  164. let data = [{
  165. name: this.corporateName,
  166. list: arr
  167. }]
  168. console.log(this.form, 105);
  169. console.log(data, 120);
  170. uni.showLoading({
  171. title: '加载中',
  172. mask: true
  173. });
  174. activityGenerateOrder({
  175. payType: payType,
  176. address: this.addres.belongtoarea + this.addres.detailedAddress,
  177. list: data,
  178. }).then(res => {
  179. let generateOrderData = res.data
  180. paramserviceDetail({
  181. paramKey: 'cashier.payment'
  182. }).then(res => {
  183. let paramservice = res.data
  184. // 判断是调支付台的接口还是微信支付的接口
  185. if (paramservice && paramservice.paramValue == '1') {
  186. // uni.hideLoading();
  187. let obj = {
  188. appId: 'wxef277996acc166c3',
  189. extraData: {
  190. cusid: generateOrderData.cusid,
  191. appid: generateOrderData.appid,
  192. orgid: generateOrderData.orgid,
  193. version: generateOrderData.version,
  194. trxamt: generateOrderData.trxamt,
  195. reqsn: generateOrderData.reqsn,
  196. notify_url: generateOrderData.notify_url,
  197. body: generateOrderData.body,
  198. remark: generateOrderData.remark,
  199. validtime: generateOrderData.validtime,
  200. limit_pay: generateOrderData.limit_pay,
  201. randomstr: generateOrderData.randomstr,
  202. paytype: generateOrderData.paytype,
  203. signtype: generateOrderData.signtype,
  204. sign: generateOrderData.sign,
  205. },
  206. }
  207. console.log(obj);
  208. if (!generateOrderData.reqsn) {
  209. uni.showToast({
  210. title: '当前订单号为空,请联系供应商!!!',
  211. icon: 'none',
  212. mask: true,
  213. duration: 2000
  214. });
  215. // 详情调用
  216. return
  217. }
  218. wx.openEmbeddedMiniProgram({
  219. appId: 'wxef277996acc166c3',
  220. extraData: {
  221. cusid: generateOrderData.cusid,
  222. appid: generateOrderData.appid,
  223. orgid: generateOrderData.orgid,
  224. version: generateOrderData.version,
  225. trxamt: generateOrderData.trxamt,
  226. reqsn: generateOrderData.reqsn,
  227. notify_url: generateOrderData.notify_url,
  228. body: generateOrderData.body,
  229. remark: generateOrderData.remark,
  230. validtime: generateOrderData.validtime,
  231. // limit_pay: generateOrderData.limit_pay,
  232. limit_pay: "",
  233. randomstr: generateOrderData.randomstr,
  234. paytype: generateOrderData.paytype,
  235. signtype: generateOrderData.signtype,
  236. sign: generateOrderData.sign,
  237. },
  238. success: (a) => {
  239. uni.hideLoading();
  240. },
  241. fail: (err) => {
  242. uni.hideLoading();
  243. }
  244. })
  245. } else {
  246. if (payType && (payType == 'W01' || payType == 'U01' || payType == 'A01' ||
  247. payType == 'S01')) {
  248. console.log(generateOrderData, 321);
  249. // 订单详情接口
  250. this.qrcodeurl = generateOrderData.url
  251. appDetail({
  252. id: generateOrderData.id
  253. }).then(res => {
  254. uni.hideLoading();
  255. this.qrcodeshow = true
  256. this.qrcodeData = res.data
  257. console.log(res.data);
  258. })
  259. } else {
  260. uni.requestPayment({
  261. provider: "wxpay",
  262. appId: generateOrderData.appId,
  263. timeStamp: generateOrderData.timeStamp,
  264. nonceStr: generateOrderData.nonceStr,
  265. package: generateOrderData.package,
  266. signType: generateOrderData.signType,
  267. paySign: generateOrderData.paySign,
  268. success(res) {
  269. uni.showToast({
  270. title: '支付成功',
  271. mask: true,
  272. duration: 2000
  273. });
  274. setTimeout(function() {
  275. uni.hideLoading();
  276. // this_.refresh(res.data.data.id)
  277. }, 1000);
  278. },
  279. fail(e) {
  280. console.log(e);
  281. uni.showToast({
  282. title: "支付失败",
  283. icon: 'none',
  284. mask: true
  285. });
  286. setTimeout(function() {
  287. uni.hideLoading();
  288. // this_.refresh(res.data.id)
  289. }, 1000);
  290. }
  291. })
  292. }
  293. }
  294. })
  295. }).catch(err => {
  296. uni.hideLoading();
  297. })
  298. },
  299. // 步进器
  300. rowNumber(value, row) {
  301. row.purchaseQuantity = value.value
  302. this.numStrip = 0
  303. this.numMoney = 0
  304. for (let item of this.form.activityItemsList) {
  305. if (item.select[0]) {
  306. this.numStrip += Number(item.purchaseQuantity)
  307. this.numMoney += Number(item.purchaseQuantity) * Number(item.priceOne)
  308. }
  309. }
  310. },
  311. // 单条选择监听
  312. rowSelect(value, row) {
  313. row.select = value
  314. this.numStrip = 0
  315. this.numMoney = 0
  316. for (let item of this.form.activityItemsList) {
  317. if (item.select[0]) {
  318. this.numStrip += Number(item.purchaseQuantity)
  319. this.numMoney += Number(item.purchaseQuantity) * Number(item.priceOne)
  320. }
  321. }
  322. },
  323. // 全选按钮监听
  324. selectAllChange(value) {
  325. this.numStrip = 0
  326. this.numMoney = 0
  327. if (value[0]) {
  328. this.selectAll = ['全选']
  329. for (let item of this.form.activityItemsList) {
  330. this.$set(item, 'select', [true])
  331. this.numStrip += Number(item.purchaseQuantity)
  332. this.numMoney += Number(item.purchaseQuantity) * Number(item.priceOne)
  333. }
  334. } else {
  335. this.selectAll = null
  336. for (let item of this.form.activityItemsList) {
  337. this.$set(item, 'select', [])
  338. }
  339. }
  340. },
  341. // 详情数据
  342. activityDetailfun(id) {
  343. activityDetail({
  344. id: id
  345. }).then(res => {
  346. const now = new Date();
  347. const end = new Date(res.data.endDate ? res.data.endDate.slice(0, 10) + ' 00:00:00' : null);
  348. let diff = end - now
  349. if (diff > 0) {
  350. this.days = Math.floor(diff / (1000 * 60 * 60 * 24))
  351. this.hours = Math.floor((diff % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); // 时
  352. this.minutes = Math.floor((diff % (1000 * 60 * 60)) / (1000 * 60)); // 分
  353. this.seconds = Math.floor((diff % (1000 * 60)) / 1000);
  354. }
  355. this.form = res.data
  356. // days:0,
  357. // hours:0,
  358. // minutes:0,
  359. // seconds:0,
  360. for (let item of this.form.activityItemsList) {
  361. this.$set(item, 'select', []) // 是否选择
  362. item.purchaseQuantity = item.minQuantity // 当前选择数据的数量
  363. }
  364. })
  365. },
  366. }
  367. }
  368. </script>
  369. <style lang="scss" scoped>
  370. .time-crad {
  371. background-color: #fff;
  372. // width: 100%;
  373. margin-top: 20rpx;
  374. padding: 32rpx;
  375. display: flex;
  376. flex-direction: column;
  377. align-items: center;
  378. .time-head {
  379. width: 650rpx;
  380. height: 104rpx;
  381. background: #FAE5DF;
  382. border-radius: 10rpx;
  383. display: flex;
  384. flex-direction: column;
  385. align-items: center;
  386. padding: 22rpx;
  387. .time-title {
  388. font-family: Source Han Sans CN;
  389. font-weight: 500;
  390. font-size: 34rpx;
  391. color: #E75F37;
  392. line-height: 38rpx;
  393. }
  394. .time-content {
  395. display: flex;
  396. align-items: center;
  397. padding-top: 30rpx;
  398. .time-text {
  399. display: flex;
  400. align-items: center;
  401. font-family: Source Han Sans CN;
  402. font-weight: 400;
  403. font-size: 26rpx;
  404. color: #E75F37;
  405. .time-text2 {
  406. margin: 0 8rpx;
  407. width: 183rpx;
  408. height: 39rpx;
  409. border-radius: 20rpx;
  410. border: 2rpx solid #E75F37;
  411. text-align: center;
  412. }
  413. }
  414. }
  415. }
  416. .time-foot {
  417. display: flex;
  418. flex-direction: column;
  419. align-items: center;
  420. .time-text {
  421. font-family: Source Han Sans CN;
  422. font-weight: 400;
  423. font-size: 34rpx;
  424. color: #959595;
  425. line-height: 38rpx;
  426. margin: 24rpx 0 16rpx 0;
  427. }
  428. }
  429. }
  430. .card {
  431. background: #FFFFFF;
  432. padding: 32rpx;
  433. margin: 20rpx 0;
  434. ::v-deep .u-checkbox__icon-wrap {
  435. border-color: #E75F37 !important;
  436. }
  437. ::v-deep .u-number-box {
  438. border: 2rpx #E1E1E1 solid;
  439. border-radius: 8rpx;
  440. }
  441. ::v-deep .u-number-box__minus {
  442. border-right: 2rpx #E1E1E1 solid;
  443. }
  444. ::v-deep .u-number-box__plus {
  445. border-left: 2rpx #E1E1E1 solid;
  446. }
  447. }
  448. .submitBar {
  449. position: fixed;
  450. bottom: 0;
  451. background-color: #fff;
  452. width: 100%;
  453. height: 290rpx;
  454. z-index: 10;
  455. ::v-deep .u-checkbox__icon-wrap {
  456. border-color: #E75F37 !important;
  457. }
  458. .left-btn {
  459. background-color: #c8c9cc;
  460. color: #fff;
  461. font-size: 26rpx;
  462. width: 180rpx;
  463. height: 65rpx;
  464. display: flex;
  465. justify-content: center;
  466. align-items: center;
  467. border-radius: 33rpx;
  468. }
  469. .right-btn {
  470. background-color: #E75F37;
  471. color: #fff;
  472. font-size: 26rpx;
  473. width: 180rpx;
  474. height: 65rpx;
  475. display: flex;
  476. justify-content: center;
  477. align-items: center;
  478. border-radius: 33rpx;
  479. }
  480. }
  481. </style>