save-order.vue 7.1 KB

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