save-order.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  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. groupOrderFoster
  76. } from '@/api/groupOrder.js';
  77. import tools from "@/service/tools";
  78. export default {
  79. data() {
  80. return {
  81. isCode: false,
  82. codeText: '获取验证码',
  83. fromData: {
  84. name: '',
  85. id: '',
  86. phone: '',
  87. school_id: '',
  88. code: '',
  89. note: '',
  90. address: '',
  91. },
  92. isAJAX: false,
  93. goodsData: {},
  94. }
  95. },
  96. onLoad(e) {
  97. if (e.goodsData) {
  98. let obj = JSON.parse(decodeURIComponent(e.goodsData));
  99. this.goodsData = obj;
  100. this.fromData.id = obj.id;
  101. }
  102. },
  103. mounted() {
  104. this.getfromData()
  105. },
  106. methods: {
  107. getfromData() {
  108. groupOrderFoster().then((res) => {
  109. if (res.code == 1) {
  110. console.log(res);
  111. this.fromData.address = res.data.address
  112. this.fromData.name = res.data.name
  113. this.fromData.phone = res.data.phone
  114. }
  115. })
  116. },
  117. getCode() {
  118. if (!this.fromData.phone) {
  119. return tools.error('请输入手机号')
  120. }
  121. if (this.isCode) {
  122. return
  123. }
  124. this.isCode = true;
  125. getCode({
  126. phone: this.fromData.phone,
  127. send_type: 'group_order'
  128. }).then((res) => {
  129. if (res.code === 1) {
  130. this.codeText = 60;
  131. let timer = setInterval(() => {
  132. this.codeText -= 1;
  133. if (this.codeText <= 0) {
  134. clearInterval(timer);
  135. this.isCode = false;
  136. this.codeText = '获取验证码'
  137. }
  138. }, 1000);
  139. } else {
  140. this.isCode = false;
  141. tools.error('获取验证码失败,请稍后重试')
  142. }
  143. })
  144. },
  145. toSave() {
  146. if (this.isAJAX) {
  147. return
  148. }
  149. this.isAJAX = true;
  150. this.fromData.school_id = uni.getStorageSync('school_id');
  151. groupCreate(this.fromData).then((res) => {
  152. if (res.code === 1) {
  153. groupPay({
  154. order_id: res.data.order_id
  155. }).then((ret) => {
  156. if (ret.code === 1) {
  157. uni.requestPayment({
  158. provider: "wxpay", //支付类型-固定值
  159. timeStamp: ret.data.wx_pay.timeStamp + "", // 时间戳(单位:秒)
  160. nonceStr: ret.data.wx_pay.nonceStr, // 随机字符串
  161. package: ret.data.wx_pay.package, // 固定值
  162. signType: ret.data.wx_pay.signType, //固定值
  163. paySign: ret.data.wx_pay.paySign, //签名
  164. success: (ren) => {
  165. this.isAJAX = false;
  166. tools.success("支付成功");
  167. uni.setStorageSync('orderPayType', 3)
  168. setTimeout(() => {
  169. uni.switchTab({
  170. url: "/pages/order/index"
  171. })
  172. }, 1000)
  173. },
  174. fail: (err) => {
  175. this.isAJAX = false;
  176. tools.error("支付失败");
  177. uni.setStorageSync('orderPayType', 3)
  178. setTimeout(() => {
  179. uni.switchTab({
  180. url: "/pages/order/index"
  181. })
  182. }, 1000)
  183. },
  184. });
  185. } else {
  186. this.isAJAX = false;
  187. tools.error("支付失败");
  188. uni.setStorageSync('orderPayType', 3)
  189. setTimeout(() => {
  190. uni.switchTab({
  191. url: "/pages/order/index"
  192. })
  193. }, 1000)
  194. }
  195. })
  196. } else {
  197. this.isAJAX = false;
  198. tools.error(res.msg);
  199. }
  200. })
  201. },
  202. },
  203. }
  204. </script>
  205. <style scoped lang="scss">
  206. .save-order-box {
  207. position: relative;
  208. .right-only-right-red {
  209. width: 44rpx;
  210. height: 44rpx;
  211. line-height: 40rpx;
  212. border-radius: 12rpx;
  213. border: 1rpx solid #41ABF5;
  214. color: #41ABF5;
  215. }
  216. .right-only-right-add {
  217. width: 44rpx;
  218. height: 44rpx;
  219. line-height: 40rpx;
  220. background: linear-gradient(117deg, #57CAFF 0%, #41ABF5 100%);
  221. border-radius: 12rpx;
  222. }
  223. .right-only-right-2 {
  224. min-width: 50rpx;
  225. }
  226. .bg-box {
  227. width: 100%;
  228. height: 448rpx;
  229. filter: blur(80rpx);
  230. background: linear-gradient(to right, rgba(176, 252, 250, 0.6), rgba(249, 246, 224, 0.87), rgba(249, 246, 224, 0.87));
  231. position: absolute;
  232. top: 0;
  233. left: 0;
  234. z-index: -1;
  235. }
  236. .bottom-box {
  237. background-color: #fff;
  238. .box-1 {
  239. flex: 1;
  240. height: 100rpx;
  241. background: #333;
  242. border-radius: 200rpx 0rpx 0rpx 200rpx;
  243. box-sizing: border-box;
  244. padding-left: 32rpx;
  245. padding-bottom: 20rpx;
  246. }
  247. .box-2 {
  248. width: 200rpx;
  249. height: 100rpx;
  250. line-height: 100rpx;
  251. background: #41ABF5;
  252. border-radius: 0rpx 200rpx 200rpx 0rpx;
  253. text-align: center;
  254. }
  255. }
  256. .box-card {
  257. width: 100%;
  258. min-height: 88rpx;
  259. border-radius: 20rpx;
  260. padding: 24rpx 24rpx 0 24rpx;
  261. .box-top {
  262. padding-bottom: 24rpx;
  263. border-bottom: 2rpx solid #F9F9F9;
  264. margin-bottom: 24rpx;
  265. .box-left {
  266. image {
  267. width: 108rpx;
  268. height: 108rpx;
  269. border-radius: 8rpx;
  270. margin-right: 16rpx;
  271. }
  272. .w336 {
  273. width: 336rpx;
  274. }
  275. }
  276. }
  277. .box-buttom {
  278. padding-bottom: 24rpx;
  279. }
  280. }
  281. .box-input {
  282. border-bottom: 2rpx solid #F9F9F9;
  283. position: relative;
  284. .w158 {
  285. width: 158rpx;
  286. }
  287. input {
  288. font-size: 28rpx;
  289. }
  290. .code-box {
  291. position: absolute;
  292. right: 0;
  293. top: 0;
  294. }
  295. }
  296. .wx-box {
  297. image {
  298. width: 40rpx;
  299. height: 40rpx;
  300. }
  301. }
  302. }
  303. </style>