save-dry.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. <template>
  2. <view class="save-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 align-items-center box-border-box p-b-20 mb-20">
  8. <view class="fs-28 fw-600 w158">姓名</view>
  9. <input v-model="fromData.name" type="text" placeholder="请输入姓名">
  10. </view>
  11. <view class="box-input align-items-center box-border-box p-b-20 mb-20">
  12. <view class="fs-28 fw-600 w158">手机号</view>
  13. <input v-model="fromData.phone" type="number" placeholder="请输入手机号">
  14. <view class="fs-28 fc-41ABF5 code-box" @click="getCode()">{{codeText}}{{isCode?'s':''}}</view>
  15. </view>
  16. <view class="box-input align-items-center box-border-box p-b-20 mb-20">
  17. <view class="fs-28 fw-600 w158">验证码</view>
  18. <input v-model="fromData.code" type="number" placeholder="请输入验证码">
  19. </view>
  20. <view class="box-input align-items-center box-border-box p-b-20 mb-20">
  21. <view class="fs-28 fw-600 w158">联系地址</view>
  22. <input v-model="fromData.address" type="text" placeholder="请输入联系地址(选填)">
  23. </view>
  24. </view>
  25. <view class="box-card box-border-box mb-20 bgc-f">
  26. <view class="box-top box-border-box flex-justify-space" v-for="(item,i) in cardData.goods_list" :key="i">
  27. <view class="box-left display-flex">
  28. <image :src="item.goods_image" mode="aspectFill"></image>
  29. <view class="w336 fs-28 fw-400">{{item.goods_name||''}}</view>
  30. </view>
  31. <view class="box-right">
  32. <view class="fs-32 fw-600 text-align-right mb-12">¥{{item.price||''}}</view>
  33. <view class="display-flex align-items-center">
  34. <view class="right-only-right-red fw-500 text-align-center fs-36 fc-f" @click="addred(1,item)">-</view>
  35. <view class="right-only-right-2 text-align-center fs-28 fw-400">{{item.number}}</view>
  36. <view class="right-only-right-add fw-500 text-align-center fs-36 fc-f" @click="addred(2,item)">+</view>
  37. </view>
  38. </view>
  39. </view>
  40. <view class="box-buttom text-align-right">
  41. <span class="fs-28 fc-9 fw-400">共{{cardData.total_num||'0'}}件,</span>
  42. <span class="fs-28 fc-0 fw-400">合计¥</span>
  43. <span class="fs-44 fc-0 fw-b">{{cardData.total_price||'0'}}</span>
  44. </view>
  45. </view>
  46. <view class="box-card box-border-box mb-20 bgc-f flex-justify-space">
  47. <view class="fs-28 fw-600 w158">备注</view>
  48. <input v-model="fromData.note" class="text-align-right" type="text" placeholder="请填写你的备注">
  49. </view>
  50. <view class="box-card box-border-box mb-20 bgc-f flex-justify-space">
  51. <view class="fs-28 fw-600 w158">支付方式</view>
  52. <view class="wx-box display-flex">
  53. <image src="@/static/img/common/wx-zf.png" mode="scaleToFill"></image>
  54. <view class="fs-28 fw-400 ml-10">微信支付</view>
  55. </view>
  56. </view>
  57. </view>
  58. <view class="bottom-box box-border-box p-24">
  59. <view class="flex-justify-space">
  60. <view class="align-items-flex-end box-1">
  61. <span class="fs-28 fc-f fw-600">¥</span>
  62. <span class="fs-44 fc-f fw-600">{{cardData.total_price||'0'}}</span>
  63. </view>
  64. <view class="text-align-center box-2 fs-32 fc-f fw-600" @click="toSave()">立即支付</view>
  65. </view>
  66. </view>
  67. </view>
  68. </template>
  69. <script>
  70. import {getCode} from '@/api/common.js';
  71. import {setShopIngNumber,getShopIngList,setShopIngAdd,} from '@/api/shopping.js';
  72. import {laundryCreate} from '@/api/laundry.js';
  73. import {laundryPay} from '@/api/laundryOrder.js';
  74. import tools from "@/service/tools";
  75. export default {
  76. data(){
  77. return{
  78. isCode:false,
  79. codeText:'获取验证码',
  80. fromData:{
  81. name:'',
  82. code:'',
  83. address:'',
  84. phone:'',
  85. note:'',
  86. site_id:'',
  87. school_id:'',
  88. },
  89. isAJAX:false,
  90. goodsData:{},
  91. cardData:{
  92. goods_list:[],
  93. total_num:0,
  94. total_price:0,
  95. },
  96. }
  97. },
  98. onLoad(e) {
  99. this.fromData.site_id = e.id;
  100. this.getCardList();
  101. },
  102. methods:{
  103. getCardList(){
  104. getShopIngList({type:3}).then((res)=>{
  105. if(res.code === 1){
  106. this.cardData = res.data;
  107. }
  108. })
  109. },
  110. getCode(){
  111. if (this.isCode) {
  112. return
  113. }
  114. this.isCode = true;
  115. getCode({phone:this.fromData.phone,send_type:'ticket_order'}).then((res)=>{
  116. if(res.code === 1){
  117. this.codeText = 60;
  118. let timer = setInterval(() => {
  119. this.codeText -= 1;
  120. if (this.codeText <= 0) {
  121. clearInterval(timer);
  122. this.isCode = false;
  123. this.codeText = '获取验证码'
  124. }
  125. }, 1000);
  126. }else{
  127. this.isCode = false;
  128. tools.error('获取验证码失败,请稍后重试')
  129. }
  130. })
  131. },
  132. toSave(){
  133. if (this.isAJAX) {
  134. return
  135. }
  136. this.isAJAX = true;
  137. this.fromData.school_id = uni.getStorageSync('school_id');
  138. laundryCreate(this.fromData).then((res)=>{
  139. if(res.code === 1){
  140. laundryPay({order_id:res.data.order_id}).then((ret)=>{
  141. if(ret.code === 1){
  142. uni.requestPayment({
  143. provider: "wxpay", //支付类型-固定值
  144. timeStamp: ret.data.wx_pay.timeStamp + "", // 时间戳(单位:秒)
  145. nonceStr: ret.data.wx_pay.nonceStr, // 随机字符串
  146. package: ret.data.wx_pay.package, // 固定值
  147. signType: ret.data.wx_pay.signType, //固定值
  148. paySign: ret.data.wx_pay.paySign, //签名
  149. success: (ren) => {
  150. tools.success("支付成功");
  151. this.isAJAX = false;
  152. setTimeout(()=>{
  153. uni.switchTab({
  154. url:"/pages/order/index"
  155. })
  156. },1500)
  157. },
  158. fail: (err) =>{
  159. this.isAJAX = false;
  160. tools.error("支付失败");
  161. },
  162. });
  163. }else{
  164. this.isAJAX = false;
  165. tools.error("支付失败");
  166. }
  167. })
  168. }else{
  169. this.isAJAX = false;
  170. tools.error(res.msg);
  171. }
  172. })
  173. },
  174. addred(type,info){
  175. if(this.isAJAX){
  176. return
  177. }
  178. this.isAJAX = true;
  179. if(type === 1){
  180. if(info.number <= 1){
  181. this.isAJAX = false;
  182. }else{
  183. // 减
  184. setShopIngNumber({type:3,goods_id:info.goods_id,category_id:info.category_id,operation:2}).then((res)=>{
  185. if(res.code === 1){
  186. this.isAJAX = false;
  187. info.number -= 1;
  188. this.getCardList();
  189. }else{
  190. this.isAJAX = false;
  191. tools.error(res.msg)
  192. }
  193. })
  194. }
  195. }else if(type === 2){
  196. // 加
  197. setShopIngAdd({type:3,goods_id:info.goods_id,category_id:info.category_id}).then((res)=>{
  198. if(res.code === 1){
  199. this.isAJAX = false;
  200. info.number += 1;
  201. this.getCardList();
  202. }else{
  203. this.isAJAX = false;
  204. tools.error(res.msg)
  205. }
  206. })
  207. }
  208. },
  209. },
  210. }
  211. </script>
  212. <style scoped lang="scss">
  213. .save-order-box{
  214. position: relative;
  215. .right-only-right-red{
  216. width: 44rpx;
  217. height: 44rpx;
  218. line-height: 40rpx;
  219. border-radius: 12rpx;
  220. border: 1rpx solid #41ABF5;
  221. color: #41ABF5;
  222. }
  223. .right-only-right-add{
  224. width: 44rpx;
  225. height: 44rpx;
  226. line-height: 40rpx;
  227. background: linear-gradient( 117deg, #57CAFF 0%, #41ABF5 100%);
  228. border-radius: 12rpx;
  229. }
  230. .right-only-right-2{
  231. min-width: 50rpx;
  232. }
  233. .bg-box{
  234. width: 100%;
  235. height: 448rpx;
  236. filter: blur(80rpx);
  237. background: linear-gradient(to right,rgba(176, 252, 250, 0.6),rgba(249,246,224,0.87),rgba(249,246,224,0.87));
  238. position: absolute;
  239. top: 0;
  240. left: 0;
  241. z-index: -1;
  242. }
  243. .bottom-box{
  244. background-color: #fff;
  245. .box-1{
  246. flex: 1;
  247. height: 100rpx;
  248. background: #333;
  249. border-radius: 200rpx 0rpx 0rpx 200rpx;
  250. box-sizing: border-box;
  251. padding-left: 32rpx;
  252. padding-bottom: 20rpx;
  253. }
  254. .box-2{
  255. width: 200rpx;
  256. height: 100rpx;
  257. line-height: 100rpx;
  258. background: #41ABF5;
  259. border-radius: 0rpx 200rpx 200rpx 0rpx;
  260. text-align: center;
  261. }
  262. }
  263. .box-card{
  264. width: 100%;
  265. min-height: 88rpx;
  266. border-radius: 20rpx;
  267. padding: 24rpx 24rpx 0 24rpx;
  268. .box-top{
  269. padding-bottom: 24rpx;
  270. border-bottom: 2rpx solid #F9F9F9;
  271. margin-bottom: 24rpx;
  272. .box-left{
  273. image{
  274. width: 108rpx;
  275. height: 108rpx;
  276. border-radius: 8rpx;
  277. margin-right: 16rpx;
  278. }
  279. .w336{
  280. width: 336rpx;
  281. }
  282. }
  283. }
  284. .box-buttom{
  285. padding-bottom: 24rpx;
  286. }
  287. }
  288. .box-input{
  289. border-bottom: 2rpx solid #F9F9F9;
  290. position: relative;
  291. .w158{
  292. width: 158rpx;
  293. }
  294. input{
  295. font-size: 28rpx;
  296. }
  297. .code-box{
  298. position: absolute;
  299. right: 0;
  300. top: 0;
  301. }
  302. }
  303. .wx-box{
  304. image{
  305. width: 40rpx;
  306. height: 40rpx;
  307. }
  308. }
  309. }
  310. </style>