confirm-order.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  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="fs-32 fc-FB3D03 fw-600">-¥3</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||0}}</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 p-b-20 mb-24">
  79. <view class="fs-28 fw-600 w158">备注</view>
  80. <input class="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||0}}</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. quanInfo:{
  143. },
  144. quanData:{
  145. coupon:[],//可用
  146. receive:[],//可领
  147. },
  148. cardData:{
  149. goods_list:[],
  150. },
  151. isAJAX:false,
  152. }
  153. },
  154. onLoad(e) {
  155. this.type = Number(e.type)
  156. if(e.pickup_code){
  157. this.fromData.pickup_code = e.pickup_code.split(',').map(String)
  158. console.log(this.fromData.pickup_code);
  159. this.getCard();
  160. }
  161. this.getAddressDefault();
  162. this.getExpressCoupon();
  163. },
  164. methods:{
  165. // 获取购物车
  166. getCard(){
  167. getShopIngList({type:this.type}).then((res)=>{
  168. if(res.code === 1){
  169. this.cardData = res.data;
  170. }
  171. })
  172. },
  173. // 获取优惠券
  174. getExpressCoupon(){
  175. let operate_id = uni.getStorageSync('operate_id');
  176. getExpressCoupon({operate_id:operate_id}).then((res)=>{
  177. if(res.code === 1){
  178. this.quanData = res.data;
  179. }
  180. })
  181. },
  182. // 获取默认地址
  183. getAddressDefault(){
  184. getAddressDefault().then((res)=>{
  185. if(res.code === 1){
  186. this.addressData = res.data
  187. if(this.addressData.id){
  188. this.fromData.address_id = this.addressData.id;
  189. }
  190. }
  191. })
  192. },
  193. selectFun(type){
  194. if(type === 1){
  195. // 选择优惠券
  196. this.$refs.coupon.getList();
  197. }else if(type === 2){
  198. // 选择地址
  199. if(this.addressData.id){
  200. this.$refs.selectAddress.id = this.addressData.id;
  201. }
  202. this.$refs.selectAddress.getList();
  203. }else if(type === 3){
  204. // 选择时间
  205. this.$refs.selectTime.getList();
  206. }else if(type === 4){
  207. // 编辑code
  208. this.$refs.editCode.getList();
  209. }
  210. },
  211. giveCouPon(e){
  212. console.log(e);
  213. },
  214. giveAddress(e){
  215. this.addressData = e;
  216. this.fromData.address_id = this.addressData.id;
  217. },
  218. giveTime(e){
  219. console.log(e);
  220. },
  221. toSave(){
  222. if(!this.fromData.address_id){
  223. return tools.error('请先选择地址')
  224. }
  225. if(this.isAJAX){
  226. return
  227. }
  228. this.isAJAX = true;
  229. this.fromData.school_id = uni.getStorageSync('school_id');
  230. this.fromData.site_id = uni.getStorageSync('site_id');
  231. getExpressCreate(this.fromData).then((res)=>{
  232. if(res.code === 1){
  233. getExpressPay({order_id:res.data.order_id}).then((ret)=>{
  234. if(ret.code === 1){
  235. uni.requestPayment({
  236. provider: "wxpay", //支付类型-固定值
  237. timeStamp: ret.data.wx_pay.timeStamp + "", // 时间戳(单位:秒)
  238. nonceStr: ret.data.wx_pay.nonceStr, // 随机字符串
  239. package: ret.data.wx_pay.package, // 固定值
  240. signType: ret.data.wx_pay.signType, //固定值
  241. paySign: ret.data.wx_pay.paySign, //签名
  242. success: (ren) => {
  243. tools.success("支付成功");
  244. this.isAJAX = false;
  245. setTimeout(()=>{
  246. uni.switchTab({
  247. url:"/pages/index/index"
  248. })
  249. },1500)
  250. },
  251. fail: (err) =>{
  252. this.isAJAX = false;
  253. tools.error("支付失败");
  254. },
  255. });
  256. }
  257. })
  258. }
  259. })
  260. },
  261. },
  262. }
  263. </script>
  264. <style scoped lang="scss">
  265. .code-box{
  266. min-height: 100rpx;
  267. background-color: #F3F4F6;
  268. border-radius: 12rpx;
  269. padding: 24rpx 24rpx 0 24rpx;
  270. .code-item{
  271. width: 156rpx;
  272. margin-right: 52rpx;
  273. margin-bottom: 16rpx;
  274. }
  275. .code-item:nth-child(3n){
  276. margin-right: 0 !important;
  277. }
  278. }
  279. .tz-an-f{
  280. position: relative;
  281. .tz-an{
  282. position: absolute;
  283. right: 16rpx;
  284. top: 0;
  285. }
  286. }
  287. .r-right{
  288. margin-top: 24rpx;
  289. width: 88rpx;
  290. height: 52rpx;
  291. border-radius: 200rpx;
  292. position: relative;
  293. .r-y{
  294. width: 44rpx;
  295. height: 44rpx;
  296. background: #FFFFFF;
  297. border-radius: 200rpx;
  298. position: absolute;
  299. top: 4rpx;
  300. }
  301. }
  302. .s-r{
  303. background-color: #41ABF5;
  304. transition: all 1s;
  305. .r-y{
  306. right: 4rpx !important;
  307. transition: all 1s;
  308. }
  309. }
  310. .n-r{
  311. background-color: #ccc;
  312. transition: all 1s;
  313. .r-y{
  314. left: 4rpx !important;
  315. transition: all 1s;
  316. }
  317. }
  318. .goods-img{
  319. width: 108rpx;
  320. height: 108rpx;
  321. border-radius: 8rpx;
  322. margin-right: 16rpx;
  323. }
  324. .right-icon{
  325. width: 32rpx;
  326. height: 32rpx;
  327. }
  328. .w376{
  329. width: 376rpx;
  330. }
  331. .w570{
  332. width: 570rpx;
  333. }
  334. .sd-box{
  335. padding: 3rpx 16rpx;
  336. height: 40rpx;
  337. line-height: 40rpx;
  338. background: rgba(251,61,3,0.1);
  339. border-radius: 8rpx 8rpx 8rpx 8rpx;
  340. }
  341. .confirm-order-box{
  342. position: relative;
  343. .bg-box{
  344. width: 100%;
  345. height: 448rpx;
  346. filter: blur(80rpx);
  347. background: linear-gradient(to right,rgba(176, 252, 250, 0.6),rgba(249,246,224,0.87),rgba(249,246,224,0.87));
  348. position: absolute;
  349. top: 0;
  350. left: 0;
  351. z-index: -1;
  352. }
  353. .bottom-box{
  354. background-color: #fff;
  355. .box-1{
  356. flex: 1;
  357. height: 100rpx;
  358. background: #333;
  359. border-radius: 200rpx 0rpx 0rpx 200rpx;
  360. box-sizing: border-box;
  361. padding-left: 32rpx;
  362. padding-bottom: 20rpx;
  363. }
  364. .box-2{
  365. width: 200rpx;
  366. height: 100rpx;
  367. line-height: 100rpx;
  368. background: #41ABF5;
  369. border-radius: 0rpx 200rpx 200rpx 0rpx;
  370. text-align: center;
  371. }
  372. }
  373. .box-card{
  374. width: 100%;
  375. min-height: 88rpx;
  376. border-radius: 20rpx;
  377. padding: 24rpx 24rpx 0 24rpx;
  378. }
  379. .wx-box{
  380. image{
  381. width: 40rpx;
  382. height: 40rpx;
  383. }
  384. }
  385. .box-input{
  386. border-bottom: 2rpx solid #F9F9F9;
  387. }
  388. }
  389. </style>