save-order.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  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>
  15. <view class="box-input align-items-center box-border-box p-b-20 mb-20">
  16. <view class="fs-28 fw-600 w158">验证码</view>
  17. <input v-model="fromData.code" type="number" placeholder="请输入验证码">
  18. <view class="fs-28 fc-41ABF5 code-box" @click="getCode()">{{codeText}}{{isCode?'s':''}}</view>
  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">
  27. <view class="box-left display-flex">
  28. <image :src="goodsData.cover_img" mode="aspectFill"></image>
  29. <view class="">
  30. <view class="w336 fs-28 fw-400 mb-4">{{goodsData.title||''}}</view>
  31. <view class="fs-28 fc-9">
  32. x 1
  33. </view>
  34. </view>
  35. </view>
  36. <view class="box-right">
  37. <view class="fs-32 fw-600 text-align-right mb-12">¥{{goodsData.price || '0'}}</view>
  38. </view>
  39. </view>
  40. <view class="box-buttom text-align-right">
  41. <span class="fs-28 fc-0 fw-400">定金¥</span>
  42. <span class="fs-44 fc-0 fw-b">{{goodsData.deposit||'0'}}</span>
  43. </view>
  44. </view>
  45. <view class="box-card box-border-box mb-20 bgc-f flex-justify-space">
  46. <view class="fs-28 fw-600 w158">备注</view>
  47. <input v-model="fromData.note" class="text-align-right" type="text" placeholder="请填写你的备注">
  48. </view>
  49. <view class="box-card box-border-box mb-20 bgc-f flex-justify-space">
  50. <view class="fs-28 fw-600 w158">支付方式</view>
  51. <view class="wx-box display-flex">
  52. <image src="@/static/img/common/wx-zf.png" mode="scaleToFill"></image>
  53. <view class="fs-28 fw-400 ml-10">微信支付</view>
  54. </view>
  55. </view>
  56. </view>
  57. <view class="bottom-box box-border-box p-24">
  58. <view class="flex-justify-space">
  59. <view class="align-items-flex-end box-1">
  60. <span class="fs-28 fc-f fw-600">¥</span>
  61. <span class="fs-44 fc-f fw-600">{{goodsData.deposit||''}}</span>
  62. </view>
  63. <view class="text-align-center box-2 fs-32 fc-f fw-600" @click="toSave()">立即支付</view>
  64. </view>
  65. </view>
  66. </view>
  67. </template>
  68. <script>
  69. import {
  70. getCode
  71. } from '@/api/common.js';
  72. import {
  73. groupPay,
  74. groupCreate
  75. } from '@/api/groupOrder.js';
  76. import tools from "@/service/tools";
  77. export default {
  78. data() {
  79. return {
  80. isCode: false,
  81. codeText: '获取验证码',
  82. fromData: {
  83. name: '',
  84. id: '',
  85. phone: '',
  86. school_id: '',
  87. code: '',
  88. note: '',
  89. address: '',
  90. },
  91. isAJAX: false,
  92. goodsData: {},
  93. }
  94. },
  95. onLoad(e) {
  96. if (e.goodsData) {
  97. let obj = JSON.parse(decodeURIComponent(e.goodsData));
  98. this.goodsData = obj;
  99. this.fromData.id = obj.id;
  100. console.log(this.goodsData, '*********');
  101. }
  102. },
  103. methods: {
  104. getCode() {
  105. if (!this.fromData.phone) {
  106. return tools.error('请输入手机号')
  107. }
  108. if (this.isCode) {
  109. return
  110. }
  111. this.isCode = true;
  112. getCode({
  113. phone: this.fromData.phone,
  114. send_type: 'group_order'
  115. }).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. groupCreate(this.fromData).then((res) => {
  139. if (res.code === 1) {
  140. groupPay({
  141. order_id: res.data.order_id
  142. }).then((ret) => {
  143. if (ret.code === 1) {
  144. uni.requestPayment({
  145. provider: "wxpay", //支付类型-固定值
  146. timeStamp: ret.data.wx_pay.timeStamp + "", // 时间戳(单位:秒)
  147. nonceStr: ret.data.wx_pay.nonceStr, // 随机字符串
  148. package: ret.data.wx_pay.package, // 固定值
  149. signType: ret.data.wx_pay.signType, //固定值
  150. paySign: ret.data.wx_pay.paySign, //签名
  151. success: (ren) => {
  152. this.isAJAX = false;
  153. tools.success("支付成功");
  154. uni.setStorageSync('orderPayType', 3)
  155. setTimeout(() => {
  156. uni.switchTab({
  157. url: "/pages/order/index"
  158. })
  159. }, 1000)
  160. },
  161. fail: (err) => {
  162. this.isAJAX = false;
  163. tools.error("支付失败");
  164. uni.setStorageSync('orderPayType', 3)
  165. setTimeout(() => {
  166. uni.switchTab({
  167. url: "/pages/order/index"
  168. })
  169. }, 1000)
  170. },
  171. });
  172. } else {
  173. this.isAJAX = false;
  174. tools.error("支付失败");
  175. uni.setStorageSync('orderPayType', 3)
  176. setTimeout(() => {
  177. uni.switchTab({
  178. url: "/pages/order/index"
  179. })
  180. }, 1000)
  181. }
  182. })
  183. } else {
  184. this.isAJAX = false;
  185. tools.error(res.msg);
  186. }
  187. })
  188. },
  189. },
  190. }
  191. </script>
  192. <style scoped lang="scss">
  193. .save-order-box {
  194. position: relative;
  195. .right-only-right-red {
  196. width: 44rpx;
  197. height: 44rpx;
  198. line-height: 40rpx;
  199. border-radius: 12rpx;
  200. border: 1rpx solid #41ABF5;
  201. color: #41ABF5;
  202. }
  203. .right-only-right-add {
  204. width: 44rpx;
  205. height: 44rpx;
  206. line-height: 40rpx;
  207. background: linear-gradient(117deg, #57CAFF 0%, #41ABF5 100%);
  208. border-radius: 12rpx;
  209. }
  210. .right-only-right-2 {
  211. min-width: 50rpx;
  212. }
  213. .bg-box {
  214. width: 100%;
  215. height: 448rpx;
  216. filter: blur(80rpx);
  217. background: linear-gradient(to right, rgba(176, 252, 250, 0.6), rgba(249, 246, 224, 0.87), rgba(249, 246, 224, 0.87));
  218. position: absolute;
  219. top: 0;
  220. left: 0;
  221. z-index: -1;
  222. }
  223. .bottom-box {
  224. background-color: #fff;
  225. .box-1 {
  226. flex: 1;
  227. height: 100rpx;
  228. background: #333;
  229. border-radius: 200rpx 0rpx 0rpx 200rpx;
  230. box-sizing: border-box;
  231. padding-left: 32rpx;
  232. padding-bottom: 20rpx;
  233. }
  234. .box-2 {
  235. width: 200rpx;
  236. height: 100rpx;
  237. line-height: 100rpx;
  238. background: #41ABF5;
  239. border-radius: 0rpx 200rpx 200rpx 0rpx;
  240. text-align: center;
  241. }
  242. }
  243. .box-card {
  244. width: 100%;
  245. min-height: 88rpx;
  246. border-radius: 20rpx;
  247. padding: 24rpx 24rpx 0 24rpx;
  248. .box-top {
  249. padding-bottom: 24rpx;
  250. border-bottom: 2rpx solid #F9F9F9;
  251. margin-bottom: 24rpx;
  252. .box-left {
  253. image {
  254. width: 108rpx;
  255. height: 108rpx;
  256. border-radius: 8rpx;
  257. margin-right: 16rpx;
  258. }
  259. .w336 {
  260. width: 336rpx;
  261. }
  262. }
  263. }
  264. .box-buttom {
  265. padding-bottom: 24rpx;
  266. }
  267. }
  268. .box-input {
  269. border-bottom: 2rpx solid #F9F9F9;
  270. position: relative;
  271. .w158 {
  272. width: 158rpx;
  273. }
  274. input {
  275. font-size: 28rpx;
  276. }
  277. .code-box {
  278. position: absolute;
  279. right: 0;
  280. top: 0;
  281. }
  282. }
  283. .wx-box {
  284. image {
  285. width: 40rpx;
  286. height: 40rpx;
  287. }
  288. }
  289. }
  290. </style>