confirm-order.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  1. <template>
  2. <view class="confirm-order-box iPhone-bottom flex-common-css box-border-box">
  3. <view class="bg-box"></view>
  4. <Nav title='提交订单' bgckgroundBox='transparent'></Nav>
  5. <view class="scroll-view-css box-border-box p-24">
  6. <view class="box-card box-border-box mb-20 bgc-f">
  7. <view class="box-input box-border-box p-b-20 mb-20" @click="selectFun(2)">
  8. <view class="flex-justify-space mb-12">
  9. <view v-if="addressData.id" class="fs-36 fw-600 text-overflow-ellipsis w570">{{addressData.address||''}}{{addressData.school_name||''}}{{addressData.dorm_name||''}}</view>
  10. <view v-else class="fs-36 fw-600 text-overflow-ellipsis w570">请选择地址</view>
  11. <image class="right-icon" src="@/static/img/toRight.png" mode=""></image>
  12. </view>
  13. <view class="" v-if="addressData.id">
  14. <span class="mr-24 fs-28 fc-9">{{addressData.consignee||''}}</span><span class="fs-28 fc-9">{{addressData.phone||''}}</span>
  15. </view>
  16. </view>
  17. <!-- <view class="box-input flex-justify-space align-items-center box-border-box p-b-20 mb-20" @click="selectFun(3)">
  18. <view class="fs-28 fw-600">预计送达</view>
  19. <view class="align-items-center">
  20. <view class="fs-28 fw-400 fc-41ABF5">预计 12:30 送达</view>
  21. <image class="right-icon" src="@/static/img/toRight.png" mode=""></image>
  22. </view>
  23. </view> -->
  24. <!-- <view class="box-input flex-justify-space box-border-box p-b-20 mb-20">
  25. <view class="fs-28 fw-600">配送方式</view>
  26. <view class="fs-24 fw-400 sd-box fc-FB3D03">送达宿舍</view>
  27. </view> -->
  28. <view class="p-b-20">
  29. <view class=" flex-justify-space box-border-box p-b-20">
  30. <view class="fs-28 fw-600">取件码</view>
  31. <view class="align-items-center" @click="selectFun(4)">
  32. <view class="fs-24 fw-400 fc-9">修改</view>
  33. <image class="right-icon" src="@/static/img/toRight.png" mode=""></image>
  34. </view>
  35. </view>
  36. <view class="code-box box-border-box flex-wrap-wrap">
  37. <view class="code-item fs-28 text-overflow-ellipsis-one" v-for="(item,i) in fromData.pickup_code" :key="i">{{item}}</view>
  38. </view>
  39. </view>
  40. </view>
  41. <view class="box-card box-border-box bgc-f mb-20">
  42. <view class="mb-32 b-b-F9F9F9">
  43. <!-- <view class="fs-28 fw-600 mb-24">宋氏重庆鸡公煲(重工业店)宋氏重庆鸡公煲(重工业店)宋氏重庆鸡公煲(重工业店)</view> -->
  44. <view class="flex-justify-space mb-28" v-for="(item,i) in cardData.goods_list" :key="i">
  45. <image class="goods-img" :src="item.serve_image" mode="aspectFill"></image>
  46. <view class="w376">
  47. <view class="fs-28 fw-400 mb-4">
  48. {{item.serve_name}}
  49. </view>
  50. <view class="fs-24 fc-9 mb-4">{{item.serve_desc}}</view>
  51. <view class="fs-24 fc-9">x{{item.number}}</view>
  52. </view>
  53. <view class="fs-32 fw-600">¥{{Number(item.number * Number(item.price)).toFixed(2)}}</view>
  54. </view>
  55. </view>
  56. <!-- <view class="flex-justify-space mb-24">
  57. <view class="fs-28 fw-400">打包费</view>
  58. <view class="fs-32 fw-600">¥3</view>
  59. </view> -->
  60. <!-- <view class="flex-justify-space mb-24">
  61. <view class="fs-28 fw-400">配送费</view>
  62. <view class="fs-32 fw-600">¥3</view>
  63. </view> -->
  64. <view class="flex-justify-space mb-24 p-b-20 b-b-F9F9F9" @click="selectFun(1)">
  65. <view class="fs-28 fw-400">优惠券</view>
  66. <view class="align-items-center">
  67. <view :class="fromData.coupon_id?'fc-FB3D03 fw-600 fs-32':'fw-400 fs-28'">{{fromData.coupon_id?'-¥'+ quanMoney:'请选择优惠券'}}</view>
  68. <image class="right-icon" src="@/static/img/toRight.png" mode=""></image>
  69. </view>
  70. </view>
  71. <view class="text-align-right p-b-20">
  72. <span class="fc-9 fs-28">共{{cardData.total_num||0}}件,</span>
  73. <span class="fw-400 fc-0 fs-28">合计¥</span>
  74. <span class="fw-600 fc-0 fs-44">{{((cardData.total_price - quanMoney) < 0?'0':(cardData.total_price - quanMoney)||0).toFixed(2)}}</span>
  75. </view>
  76. </view>
  77. <view class="box-card box-border-box bgc-f mb-20">
  78. <view class="flex-justify-space b-b-F9F9F9 mb-24">
  79. <view class="fs-28 fw-600 w158 mr-12">备注</view>
  80. <input class="flex-1 text-align-right fs-28" type="text" placeholder="请填写你的备注">
  81. </view>
  82. <!-- <view class="fs-28 fw-600 mb-16">平台将通过服务通知向你推送最新动态</view>
  83. <view class="p-16 bgc-F3F4F6 b-rad-12 tz-an-f">
  84. <view class="fc-0 fw-400 fs-24 mb-4">是否电话通知</view>
  85. <view class="fc-9 fw-400 fs-24">若开启,则订单送达系统自动曝光(电话)通知</view>
  86. <view class="tz-an">
  87. <view class="r-right" @click="fromData.is_default == 1?fromData.is_default=0:fromData.is_default=1"
  88. :class="fromData.is_default == 0?'n-r':'s-r'">
  89. <view class="r-y"></view>
  90. </view>
  91. </view>
  92. </view> -->
  93. <view class="p-b-20"></view>
  94. </view>
  95. <view class="box-card box-border-box mb-20 bgc-f flex-justify-space">
  96. <view class="fs-28 fw-600 w158">支付方式</view>
  97. <view class="wx-box display-flex">
  98. <image src="@/static/img/common/wx-zf.png" mode="scaleToFill"></image>
  99. <view class="fs-28 fw-400 ml-10">微信支付</view>
  100. </view>
  101. </view>
  102. </view>
  103. <view class="bottom-box box-border-box p-24">
  104. <view class="flex-justify-space">
  105. <view class="align-items-flex-end box-1">
  106. <span class="fs-28 fc-f fw-600">¥</span>
  107. <span class="fs-44 fc-f fw-600">{{((cardData.total_price - quanMoney) < 0?'0':(cardData.total_price - quanMoney)||0).toFixed(2)}}</span>
  108. </view>
  109. <view class="text-align-center box-2 fs-32 fc-f fw-600" @click="toSave()">立即支付</view>
  110. </view>
  111. </view>
  112. <Coupon ref="coupon" @giveCouPon='giveCouPon'></Coupon>
  113. <SelectAddress ref="selectAddress" @giveAddress='giveAddress'></SelectAddress>
  114. <Time ref="selectTime" @giveTime='giveTime'></Time>
  115. <EditCode ref='editCode' v-model="fromData.pickup_code"></EditCode>
  116. </view>
  117. </template>
  118. <script>
  119. import {getExpressCoupon,getExpressCreate,getExpressPay} from '@/api/express.js';
  120. import {getAddressDefault} from '@/api/member.js'
  121. import {getShopIngList} from '@/api/shopping.js'
  122. import tools from "@/service/tools";
  123. import Coupon from './confirm-mod/coupon.vue';
  124. import SelectAddress from './confirm-mod/select-address.vue';
  125. import Time from './confirm-mod/time.vue';
  126. import EditCode from './confirm-mod/edit-code.vue';
  127. export default {
  128. components:{Coupon,SelectAddress,Time,EditCode},
  129. data(){
  130. return{
  131. type:2,//1外卖 2代取 3干洗
  132. fromData:{
  133. school_id:'',
  134. site_id:'',
  135. address_id:'',
  136. coupon_id:'',
  137. note:'',
  138. // is_default:0,
  139. pickup_code:[],
  140. },
  141. addressData:{},
  142. cardData:{
  143. goods_list:[],
  144. },
  145. quanMoney:"",
  146. isAJAX:false,
  147. }
  148. },
  149. onLoad(e) {
  150. this.type = Number(e.type)
  151. if(this.type == 2){
  152. this.fromData.pickup_code = e.pickup_code.split(',').map(String)
  153. this.getCard();
  154. }
  155. this.getAddressDefault();
  156. },
  157. onShow() {
  158. let isConfirmAddressFlag = uni.getStorageSync('isConfirmAddressFlag');
  159. if(isConfirmAddressFlag){
  160. this.selectFun(2);
  161. }
  162. },
  163. methods:{
  164. // 获取购物车
  165. getCard(){
  166. getShopIngList({type:this.type}).then((res)=>{
  167. if(res.code === 1){
  168. this.cardData = res.data;
  169. }
  170. })
  171. },
  172. // 获取默认地址
  173. getAddressDefault(){
  174. getAddressDefault().then((res)=>{
  175. if(res.code === 1){
  176. this.addressData = res.data
  177. if(this.addressData.id){
  178. this.fromData.address_id = this.addressData.id;
  179. }
  180. }
  181. })
  182. },
  183. selectFun(type){
  184. if(type === 1){
  185. // 选择优惠券
  186. this.$refs.coupon.getList(this.type,this.fromData.coupon_id);
  187. }else if(type === 2){
  188. // 选择地址
  189. if(this.addressData.id){
  190. this.$refs.selectAddress.id = this.addressData.id;
  191. }
  192. this.$refs.selectAddress.getList();
  193. }else if(type === 3){
  194. // 选择时间
  195. this.$refs.selectTime.getList();
  196. }else if(type === 4){
  197. // 编辑code
  198. this.$refs.editCode.getList();
  199. }
  200. },
  201. giveCouPon(e){
  202. this.quanMoney = Number(e.money);
  203. this.fromData.coupon_id = e.id;
  204. },
  205. giveAddress(e){
  206. this.addressData = e;
  207. this.fromData.address_id = this.addressData.id;
  208. },
  209. giveTime(e){
  210. console.log(e);
  211. },
  212. toSave(){
  213. if(!this.fromData.address_id){
  214. return tools.error('请先选择地址')
  215. }
  216. if(this.isAJAX){
  217. return
  218. }
  219. this.isAJAX = true;
  220. this.fromData.school_id = uni.getStorageSync('school_id');
  221. this.fromData.site_id = uni.getStorageSync('site_id');
  222. getExpressCreate(this.fromData).then((res)=>{
  223. if(res.code === 1){
  224. getExpressPay({order_id:res.data.order_id}).then((ret)=>{
  225. if(ret.code === 1){
  226. uni.requestPayment({
  227. provider: "wxpay", //支付类型-固定值
  228. timeStamp: ret.data.wx_pay.timeStamp + "", // 时间戳(单位:秒)
  229. nonceStr: ret.data.wx_pay.nonceStr, // 随机字符串
  230. package: ret.data.wx_pay.package, // 固定值
  231. signType: ret.data.wx_pay.signType, //固定值
  232. paySign: ret.data.wx_pay.paySign, //签名
  233. success: (ren) => {
  234. tools.success("支付成功");
  235. this.isAJAX = false;
  236. setTimeout(()=>{
  237. uni.switchTab({
  238. url:"/pages/order/index"
  239. })
  240. },1500)
  241. },
  242. fail: (err) =>{
  243. this.isAJAX = false;
  244. tools.error("支付失败");
  245. },
  246. });
  247. }else{
  248. this.isAJAX = false;
  249. tools.error("支付失败");
  250. }
  251. })
  252. }else{
  253. this.isAJAX = false;
  254. tools.error(res.msg);
  255. }
  256. })
  257. },
  258. },
  259. }
  260. </script>
  261. <style scoped lang="scss">
  262. .code-box{
  263. min-height: 100rpx;
  264. background-color: #F3F4F6;
  265. border-radius: 12rpx;
  266. padding: 24rpx 24rpx 0 24rpx;
  267. .code-item{
  268. width: 156rpx;
  269. margin-right: 52rpx;
  270. margin-bottom: 16rpx;
  271. }
  272. .code-item:nth-child(3n){
  273. margin-right: 0 !important;
  274. }
  275. }
  276. .tz-an-f{
  277. position: relative;
  278. .tz-an{
  279. position: absolute;
  280. right: 16rpx;
  281. top: 0;
  282. }
  283. }
  284. .r-right{
  285. margin-top: 24rpx;
  286. width: 88rpx;
  287. height: 52rpx;
  288. border-radius: 200rpx;
  289. position: relative;
  290. .r-y{
  291. width: 44rpx;
  292. height: 44rpx;
  293. background: #FFFFFF;
  294. border-radius: 200rpx;
  295. position: absolute;
  296. top: 4rpx;
  297. }
  298. }
  299. .s-r{
  300. background-color: #41ABF5;
  301. transition: all 1s;
  302. .r-y{
  303. right: 4rpx !important;
  304. transition: all 1s;
  305. }
  306. }
  307. .n-r{
  308. background-color: #ccc;
  309. transition: all 1s;
  310. .r-y{
  311. left: 4rpx !important;
  312. transition: all 1s;
  313. }
  314. }
  315. .goods-img{
  316. width: 108rpx;
  317. height: 108rpx;
  318. border-radius: 8rpx;
  319. margin-right: 16rpx;
  320. }
  321. .right-icon{
  322. width: 32rpx;
  323. height: 32rpx;
  324. }
  325. .w376{
  326. width: 376rpx;
  327. }
  328. .w570{
  329. width: 570rpx;
  330. }
  331. .sd-box{
  332. padding: 3rpx 16rpx;
  333. height: 40rpx;
  334. line-height: 40rpx;
  335. background: rgba(251,61,3,0.1);
  336. border-radius: 8rpx 8rpx 8rpx 8rpx;
  337. }
  338. .confirm-order-box{
  339. position: relative;
  340. .bg-box{
  341. width: 100%;
  342. height: 448rpx;
  343. filter: blur(80rpx);
  344. background: linear-gradient(to right,rgba(176, 252, 250, 0.6),rgba(249,246,224,0.87),rgba(249,246,224,0.87));
  345. position: absolute;
  346. top: 0;
  347. left: 0;
  348. z-index: -1;
  349. }
  350. .bottom-box{
  351. background-color: #fff;
  352. .box-1{
  353. flex: 1;
  354. height: 100rpx;
  355. background: #333;
  356. border-radius: 200rpx 0rpx 0rpx 200rpx;
  357. box-sizing: border-box;
  358. padding-left: 32rpx;
  359. padding-bottom: 20rpx;
  360. }
  361. .box-2{
  362. width: 200rpx;
  363. height: 100rpx;
  364. line-height: 100rpx;
  365. background: #41ABF5;
  366. border-radius: 0rpx 200rpx 200rpx 0rpx;
  367. text-align: center;
  368. }
  369. }
  370. .box-card{
  371. width: 100%;
  372. min-height: 88rpx;
  373. border-radius: 20rpx;
  374. padding: 24rpx 24rpx 0 24rpx;
  375. }
  376. .wx-box{
  377. image{
  378. width: 40rpx;
  379. height: 40rpx;
  380. }
  381. }
  382. .box-input{
  383. border-bottom: 2rpx solid #F9F9F9;
  384. }
  385. }
  386. </style>