save-dry.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  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. this.fromData.site_id = e.id;
  124. this.siteData_logo = e.siteData_logo
  125. this.siteData_name = e.siteData_name
  126. this.getCardList();
  127. },
  128. methods: {
  129. getCardList() {
  130. getShopIngList({
  131. type: 3
  132. }).then((res) => {
  133. if (res.code === 1) {
  134. this.cardData = res.data;
  135. }
  136. })
  137. },
  138. getCode() {
  139. if (this.isCode) {
  140. return
  141. }
  142. this.isCode = true;
  143. getCode({
  144. phone: this.fromData.phone,
  145. send_type: 'ticket_order'
  146. }).then((res) => {
  147. if (res.code === 1) {
  148. this.codeText = 60;
  149. let timer = setInterval(() => {
  150. this.codeText -= 1;
  151. if (this.codeText <= 0) {
  152. clearInterval(timer);
  153. this.isCode = false;
  154. this.codeText = '获取验证码'
  155. }
  156. }, 1000);
  157. } else {
  158. this.isCode = false;
  159. tools.error('获取验证码失败,请稍后重试')
  160. }
  161. })
  162. },
  163. toSave() {
  164. if (this.isAJAX) {
  165. return
  166. }
  167. this.isAJAX = true;
  168. this.fromData.school_id = uni.getStorageSync('school_id');
  169. laundryCreate(this.fromData).then((res) => {
  170. if (res.code === 1) {
  171. laundryPay({
  172. order_id: res.data.order_id
  173. }).then((ret) => {
  174. if (ret.code === 1) {
  175. uni.requestPayment({
  176. provider: "wxpay", //支付类型-固定值
  177. timeStamp: ret.data.wx_pay.timeStamp + "", // 时间戳(单位:秒)
  178. nonceStr: ret.data.wx_pay.nonceStr, // 随机字符串
  179. package: ret.data.wx_pay.package, // 固定值
  180. signType: ret.data.wx_pay.signType, //固定值
  181. paySign: ret.data.wx_pay.paySign, //签名
  182. success: (ren) => {
  183. tools.success("支付成功");
  184. this.isAJAX = false;
  185. setTimeout(() => {
  186. uni.switchTab({
  187. url: "/pages/order/index"
  188. })
  189. }, 1500)
  190. },
  191. fail: (err) => {
  192. this.isAJAX = false;
  193. tools.error("支付失败");
  194. },
  195. });
  196. } else {
  197. this.isAJAX = false;
  198. tools.error("支付失败");
  199. }
  200. })
  201. } else {
  202. this.isAJAX = false;
  203. tools.error(res.msg);
  204. }
  205. })
  206. },
  207. addred(type, info) {
  208. if (this.isAJAX) {
  209. return
  210. }
  211. this.isAJAX = true;
  212. if (type === 1) {
  213. if (info.number <= 1) {
  214. this.isAJAX = false;
  215. } else {
  216. // 减
  217. setShopIngNumber({
  218. type: 3,
  219. goods_id: info.goods_id,
  220. category_id: info.category_id,
  221. operation: 2
  222. }).then((res) => {
  223. if (res.code === 1) {
  224. this.isAJAX = false;
  225. info.number -= 1;
  226. this.getCardList();
  227. } else {
  228. this.isAJAX = false;
  229. tools.error(res.msg)
  230. }
  231. })
  232. }
  233. } else if (type === 2) {
  234. // 加
  235. setShopIngAdd({
  236. type: 3,
  237. goods_id: info.goods_id,
  238. category_id: info.category_id
  239. }).then((res) => {
  240. if (res.code === 1) {
  241. this.isAJAX = false;
  242. info.number += 1;
  243. this.getCardList();
  244. } else {
  245. this.isAJAX = false;
  246. tools.error(res.msg)
  247. }
  248. })
  249. }
  250. },
  251. },
  252. }
  253. </script>
  254. <style scoped lang="scss">
  255. .wh48{
  256. width: 48rpx;
  257. height: 48rpx;
  258. border-radius: 50%;
  259. }
  260. .save-order-box {
  261. position: relative;
  262. .right-only-right-red {
  263. width: 44rpx;
  264. height: 44rpx;
  265. line-height: 40rpx;
  266. border-radius: 12rpx;
  267. border: 1rpx solid #41ABF5;
  268. color: #41ABF5;
  269. }
  270. .right-only-right-add {
  271. width: 44rpx;
  272. height: 44rpx;
  273. line-height: 40rpx;
  274. background: linear-gradient(117deg, #57CAFF 0%, #41ABF5 100%);
  275. border-radius: 12rpx;
  276. }
  277. .right-only-right-2 {
  278. min-width: 50rpx;
  279. }
  280. .bg-box {
  281. width: 100%;
  282. height: 448rpx;
  283. filter: blur(80rpx);
  284. background: linear-gradient(to right, rgba(176, 252, 250, 0.6), rgba(249, 246, 224, 0.87), rgba(249, 246, 224, 0.87));
  285. position: absolute;
  286. top: 0;
  287. left: 0;
  288. z-index: -1;
  289. }
  290. .bottom-box {
  291. background-color: #fff;
  292. .box-1 {
  293. flex: 1;
  294. height: 100rpx;
  295. background: #333;
  296. border-radius: 200rpx 0rpx 0rpx 200rpx;
  297. box-sizing: border-box;
  298. padding-left: 32rpx;
  299. padding-bottom: 20rpx;
  300. }
  301. .box-2 {
  302. width: 200rpx;
  303. height: 100rpx;
  304. line-height: 100rpx;
  305. background: #41ABF5;
  306. border-radius: 0rpx 200rpx 200rpx 0rpx;
  307. text-align: center;
  308. }
  309. }
  310. .box-card {
  311. width: 100%;
  312. min-height: 88rpx;
  313. border-radius: 20rpx;
  314. padding: 24rpx 24rpx 0 24rpx;
  315. .w336 {
  316. width: 336rpx;
  317. }
  318. .box-top {
  319. padding-bottom: 24rpx;
  320. border-bottom: 2rpx solid #F9F9F9;
  321. margin-bottom: 24rpx;
  322. .box-left {
  323. image {
  324. width: 108rpx;
  325. height: 108rpx;
  326. border-radius: 8rpx;
  327. margin-right: 16rpx;
  328. }
  329. }
  330. }
  331. .box-buttom {
  332. padding-bottom: 24rpx;
  333. }
  334. }
  335. .box-input {
  336. border-bottom: 2rpx solid #F9F9F9;
  337. position: relative;
  338. .w158 {
  339. width: 158rpx;
  340. }
  341. input {
  342. font-size: 28rpx;
  343. }
  344. .code-box {
  345. position: absolute;
  346. right: 0;
  347. top: 0;
  348. }
  349. }
  350. .wx-box {
  351. image {
  352. width: 40rpx;
  353. height: 40rpx;
  354. }
  355. }
  356. }
  357. </style>