save-dry.vue 9.7 KB

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