save-ticket.vue 7.8 KB

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