save-dry.vue 10 KB

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