courseSettleCenter.vue 12 KB

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