save-dry.vue 10 KB

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