courseSettleCenter.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  1. <template>
  2. <view>
  3. <view class="common-page">
  4. <!-- 地址 -->
  5. <view class="common-card-box yuanjiao24">
  6. <view class="address-box" @click="selectAddress">
  7. <view v-if="!mAddress || !mAddress.code" class="address-view">
  8. <view style="display: flex; align-items: center;">
  9. <van-image
  10. height="36rpx"
  11. src="/static/hd-if-b.png"
  12. width="36rpx"
  13. />
  14. <text class="t1" style="margin-top: 0; margin-left: 20rpx ;font-family: PingFang SC-Medium;">请明确买家信息</text>
  15. </view>
  16. </view>
  17. <view v-if="mAddress && mAddress.code" class="address-view">
  18. <view style="display: flex; align-items: center;">
  19. <van-image
  20. height="36rpx"
  21. src="/static/hd-if-b.png"
  22. width="36rpx"
  23. />
  24. <view style="margin-top: 0; margin-left: 34rpx ;font-family: PingFang SC-Medium;">
  25. <view class="t1" space="ensp">
  26. {{ mAddress.name }} {{ mAddress.phone }}
  27. </view>
  28. <br />
  29. <view class="t2" space="emsp">
  30. {{ mAddress.province }} {{ mAddress.city }}{{ mAddress.area }}{{ mAddress.address }}
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. <u-icon name="arrow-right" color="#AEAEAE" size="34rpx"></u-icon>
  36. </view>
  37. </view>
  38. <!-- 已选商品 -->
  39. <view class="common-card-box yuanjiao24">
  40. <view class="goods-list display-flex-center" v-for="(item, index) in goodsList" :key="index">
  41. <image style="width: 155rpx; height: 155rpx; border-radius: 10rpx;margin-right: 30rpx;flex-shrink: 0;"
  42. :src="item.goods_cover" mode="aspectFill">
  43. </image>
  44. <view style="width: 100%;">
  45. <view class="display-flex-between ">
  46. <text class="goods-name">{{item.goods_name}}</text>
  47. </view>
  48. <view class="display-flex-between " style="margin-top: 30rpx">
  49. <text class="goods-price">¥<text style="font-family: D-DIN-Bold;font-weight: 700; font-size: 36rpx;">{{item.price_selling}}</text></text>
  50. </view>
  51. </view>
  52. </view>
  53. </view>
  54. <!-- 留言 -->
  55. <view class="common-card good-card yuanjiao24">
  56. <view class="fs14 mb10 good-card-text"> <view style="width: 6rpx;height: 28rpx;background: #C29556;border-radius: 0rpx 0rpx 0rpx 0rpx;margin-right: 20rpx"></view>留言</view>
  57. <u--textarea height="176rpx" v-model="order_remark" placeholder="请输入(100字以内)" class="custom-textarea" maxlength="100" count></u--textarea>
  58. </view>
  59. <van-toast id="van-toast"/>
  60. </view>
  61. <view class="bottom-navigation">
  62. <view class="bottom-navigation-div">
  63. <span>应付:<span class="space" >¥<span>{{payTotal}}</span></span></span>
  64. </view>
  65. <button class="course-button" @click="toPay">去支付</button>
  66. </view>
  67. </view>
  68. </template>
  69. <script>
  70. import couponItem from '@/subPages/coupon/couponItem.vue'
  71. export default {
  72. components: { couponItem },
  73. data() {
  74. return {
  75. orderNo: '',
  76. pageOptions: {},
  77. showCoupon: false,
  78. couponList: [],
  79. mAddress: {},
  80. usePoints: [],
  81. order_remark: '',
  82. checkedCoupon: {},
  83. goodsList: [],
  84. orderData: { amount_goods: 0, amount_express: 0 },
  85. cartIds: [],
  86. pointsData: {},
  87. pointsShowData: { price: 0, points: 0 },
  88. usePointsFlag: true,
  89. }
  90. },
  91. computed: {
  92. payTotal() {
  93. const { amount_goods = 0, amount_express = 0 } = this.orderData
  94. let result = Number(amount_goods) + Number(amount_express)
  95. if (this.checkedCoupon.coupon_id) {
  96. result = result - Number(this.checkedCoupon.coupon_price)
  97. }
  98. if (this.integral == 1) {
  99. result = result - Number(this.pointsShowData.price)
  100. }
  101. return result.toFixed(2)
  102. },
  103. userPoints() {
  104. const { integral_total = 0, integral_used = 0 } = JSON.parse(uni.getStorageSync('userInfo')||"{}");
  105. return integral_total - integral_used
  106. },
  107. pointsDisabled() {
  108. const { min_money, ratio, to_money } = this.pointsData
  109. return min_money > this.orderData.amount_goods
  110. },
  111. },
  112. onLoad(options) {
  113. this.orderNo = options.orderNo
  114. this.pageOptions = options
  115. // const mData = uni.getStorageSync('selectTaskData') || undefined
  116. },
  117. onShow() {
  118. const { type } = this.pageOptions
  119. // this.getPoints()
  120. if (type == 'cart') {
  121. // 购物车下单
  122. this.getCartData()
  123. const selectAddress = uni.getStorageSync('selectAddress') || undefined
  124. if (selectAddress) {
  125. const tempAddress = JSON.parse(selectAddress)
  126. if (!this.mAddress.code || (this.mAddress && this.mAddress.code != tempAddress.code)) {
  127. this.mAddress = tempAddress
  128. this.getExpressFee()
  129. }
  130. uni.removeStorageSync('selectAddress')
  131. }
  132. } else {
  133. this.getOrderDetail()
  134. }
  135. },
  136. methods: {
  137. getCartData() {
  138. this.cartIds = this.pageOptions.ids.split('_')
  139. this.$api.createPrevOrderByCart({ id: this.cartIds }).then(res => {
  140. const { items, coupons, count_total, amount_total, integral = {} } = res.data
  141. this.goodsList = items.map(item => {
  142. const { goods_spec, price_selling } = item.sku
  143. item.stock_sales = item.num
  144. item = {
  145. goods_spec,
  146. price_selling,
  147. ...item
  148. }
  149. return item
  150. })
  151. this.couponList = coupons
  152. // 计算付款信息等
  153. this.orderData.number_goods = count_total
  154. this.orderData.amount_goods = amount_total
  155. // const {min_money, ratio, to_money} = integral
  156. // let points = Math.floor(amount_total * ratio / 100)
  157. // points = this.userPoints > points ? points : this.usePoints
  158. if (res.data.integral_use && res.data.integral_price) {
  159. this.usePointsFlag = true
  160. this.pointsShowData = {
  161. points: res.data.integral_use,
  162. price: (res.data.integral_price).toFixed(2)
  163. }
  164. } else {
  165. this.usePointsFlag = false
  166. }
  167. })
  168. },
  169. getExpressFee() {
  170. this.$api.getPrevCartExpress({ id: this.cartIds, addr_code: this.mAddress.code }).then(res => {
  171. this.orderData.amount_express = res.data
  172. })
  173. },
  174. toPay() {
  175. if (!this.mAddress.code) {
  176. uni.showToast({
  177. title: '请选择收货地址'
  178. })
  179. return
  180. }
  181. if (this.pageOptions.type == 'cart') {
  182. const sendData = {
  183. id: this.cartIds,
  184. addr_code: this.mAddress.code,
  185. coupon_id: this.checkedCoupon.id,
  186. order_remark: this.order_remark,
  187. integral: this.integral
  188. }
  189. this.$api.createOrderByCart(sendData).then(res => {
  190. const { appId, nonceStr, paySign, signType, timeStamp } = res.data.param
  191. uni.requestPayment({
  192. provider: 'wxpay',
  193. nonceStr,
  194. package: res.data.param.package,
  195. paySign,
  196. signType,
  197. timeStamp,
  198. success: function(success) {
  199. uni.navigateTo({ url: `/subPages/paySuccess/payCourseSuccess?orderNo=${res.data.order.order_no}` })
  200. },
  201. fail: function(err) {
  202. uni.navigateTo({ url: `/subPages/orderDetail/orderDetail?orderNo=${res.data.order.order_no}` })
  203. }
  204. })
  205. })
  206. } else {
  207. // uni.navigateTo({ url: `/subPages/paySuccess/payCourseSuccess?orderNo=${this.orderNo}` })
  208. // 获取支付参数
  209. this.$toWechatPay(this.orderNo, this.order_remark,2)
  210. }
  211. },
  212. addressConfirm() {
  213. // 选择地址确认
  214. this.$api.submitOrderByAdress({ order_no: this.orderNo, code: this.mAddress.code }).then(res => {
  215. this.orderData.amount_express = res.data.amount
  216. })
  217. },
  218. getOrderDetail() {
  219. this.$api.orderDetail({ order_no: this.orderNo }).then(res => {
  220. this.goodsList = res.data.items || []
  221. this.orderData = res.data
  222. this.checkedCoupon = res.data.coupon || {}
  223. if (res.data.addr_code) {
  224. // 已选地址
  225. const {
  226. address_area,
  227. address_city,
  228. address_province,
  229. address_content,
  230. address_name,
  231. address_phone
  232. } = res.data.truck || {}
  233. this.mAddress = {
  234. code: res.data.addr_code,
  235. area: address_area,
  236. city: address_city,
  237. province: address_province,
  238. address: address_content,
  239. name: address_name,
  240. phone: address_phone
  241. }
  242. }
  243. const selectAddress = uni.getStorageSync('selectAddress') || undefined
  244. if (selectAddress) {
  245. const tempAddress = JSON.parse(selectAddress)
  246. if (!this.mAddress.code || (this.mAddress && this.mAddress.code != tempAddress.code)) {
  247. console.log(99999)
  248. this.mAddress = tempAddress
  249. this.addressConfirm()
  250. }
  251. // this.mAddress = tempAddress
  252. console.log(23333, this.mAddress);
  253. uni.removeStorageSync('selectAddress')
  254. }
  255. })
  256. },
  257. selectAddress() {
  258. uni.navigateTo({
  259. url: '/subPages/addressMg/addressMg?isBack=true'
  260. })
  261. }
  262. }
  263. }
  264. </script>
  265. <style lang="scss" scoped>
  266. .coupon-list {
  267. padding: 40rpx 20rpx;
  268. }
  269. .common-page {
  270. height: 100vh;
  271. overflow-y: auto;
  272. padding: 20rpx;
  273. color: #2C2C2C;
  274. padding-bottom: 188rpx;
  275. box-sizing: border-box;
  276. }
  277. .good-card {
  278. padding: 30rpx 20rpx 20rpx 20rpx;
  279. color: #7A7A7A;
  280. &-text{
  281. display: flex;
  282. align-items: center;
  283. font-family: PingFang SC, PingFang SC;
  284. font-weight: 400;
  285. font-size: 28rpx;
  286. color: #333333;
  287. line-height: 40rpx;
  288. text-align: left;
  289. font-style: normal;
  290. text-transform: none;
  291. // 加粗
  292. font-weight: bold;
  293. }
  294. ::v-deep {
  295. .u-textarea {
  296. background: #F6F6F6;
  297. border-radius: 24rpx 24rpx 24rpx 24rpx!important;
  298. border: none;
  299. padding: 18rpx;
  300. .u-textarea__count {
  301. background-color: transparent !important;
  302. }
  303. }
  304. }
  305. }
  306. .goods-list {
  307. margin: 0 30rpx;
  308. padding: 30rpx 0;
  309. border-bottom: 1rpx solid #F5F5F5;
  310. .goods-name{
  311. font-family: PingFang SC-Bold;
  312. font-weight: 400;
  313. font-size: 28rpx;
  314. color: #333333;
  315. line-height: 40rpx;
  316. text-align: left;
  317. font-style: normal;
  318. text-transform: none;
  319. // 加粗
  320. font-weight: bold;
  321. }
  322. .goods-price{
  323. font-family: D-DIN-Regular;
  324. font-weight: 400;
  325. font-size: 24rpx;
  326. color: #333333;
  327. line-height: 30rpx;
  328. text-align: left;
  329. font-style: normal;
  330. text-transform: none;
  331. }
  332. }
  333. .goods-total {
  334. justify-content: flex-end;
  335. margin: 27rpx 20rpx;
  336. }
  337. .address-box {
  338. // width: 100%;
  339. display: flex;
  340. flex-direction: row;
  341. align-items: center;
  342. padding: 30rpx 22rpx;
  343. .address-view {
  344. flex: 1;
  345. display: flex;
  346. flex-direction: column;
  347. .t1 {
  348. font-size: 28rpx;
  349. margin-top: 10rpx;
  350. font-family: PingFang SC-Medium, PingFang SC;
  351. font-weight: 400;
  352. color: #333333;
  353. }
  354. .t2 {
  355. font-size: 28rpx;
  356. font-family: PingFang SC-Heavy, PingFang SC;
  357. font-weight: 600;
  358. color: #333333;
  359. margin-top: 20rpx;
  360. }
  361. }
  362. }
  363. .bottom-navigation{
  364. position: fixed;
  365. // 文字垂直居中
  366. display: flex;
  367. align-items: center;
  368. justify-content: center;
  369. bottom: 0;
  370. height: 100rpx;
  371. width: calc(100% - 40rpx);
  372. background: #FFFFFF;
  373. box-shadow: 0rpx -2rpx 0rpx 0rpx #F1F3F6;
  374. border-radius: 24rpx 24rpx 0rpx 0rpx;
  375. border: 0rpx solid #979797;
  376. padding: 20rpx 20rpx 68rpx 20rpx ;
  377. &-div{
  378. height: 76rpx;
  379. width: 404rpx;
  380. // 文字垂直居中
  381. display: flex;
  382. align-items: center;
  383. padding-left: 30rpx;
  384. span{
  385. font-family: PingFang SC, PingFang SC;
  386. font-weight: 400;
  387. font-size: 28rpx;
  388. color: #333333;
  389. line-height: 40rpx;
  390. text-align: left;
  391. font-style: normal;
  392. text-transform: none;
  393. span{
  394. font-family: D-DIN-Regular;
  395. font-size: 24rpx;
  396. color: #C29556;
  397. span{
  398. font-family: D-DIN-Bold;
  399. font-size: 40rpx;
  400. }
  401. }
  402. }
  403. }
  404. .course-button {
  405. width: 264rpx;
  406. height: 80rpx;
  407. background: linear-gradient(315deg, #CA9359 0%, #E2B98E 100%);
  408. border-radius: 292rpx 292rpx 292rpx 292rpx;
  409. font-family: PingFang SC, PingFang SC;
  410. font-weight: 400;
  411. font-size: 28rpx;
  412. color: #FFFFFF;
  413. line-height: 36rpx;
  414. text-align: center;
  415. font-style: normal;
  416. text-transform: none;
  417. // 文字垂直居中
  418. display: flex;
  419. align-items: center;
  420. justify-content: center;
  421. }
  422. }
  423. .yuanjiao24{
  424. border-radius: 24rpx 24rpx 24rpx 24rpx!important;
  425. }
  426. .space::before {
  427. content: '\00A0'; /* 这是 &nbsp; 的 Unicode 码 */
  428. }
  429. </style>