海南旅游项目 前端仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

414 lines
14 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. <template>
  2. <view v-if="$isRight(goods_details)">
  3. <view class="bg-white" v-if="enter_type!=1">
  4. <view class="cu-bar1 padding-lr">
  5. <text class="lf-color-555 lf-font-28">联系人</text>
  6. <input type="text" v-model="contact" class="lf-color-999 lf-font-28 lf-text-left" style="position:absolute;right:180rpx" placeholder="请输入联系人" />
  7. </view>
  8. <view class="cu-bar1 padding-lr">
  9. <text class="lf-color-555 lf-font-28">联系方式</text>
  10. <view class="lf-row-between">
  11. <input type="text" v-model="phone" class="lf-color-999 lf-font-28 lf-text-left" style="position:absolute;right:180rpx" placeholder="请输入联系电话" maxlength="11" />
  12. </view>
  13. <button style="position: absolute;right: 0rpx;" class="lf-bg-white" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">
  14. <u-icon name="phone"></u-icon>
  15. </button>
  16. </view>
  17. <view class="cu-bar1 padding-lr" v-if="goods_type!=3">
  18. <text class="lf-color-555 lf-font-28">身份证号码</text>
  19. <input type="text" v-model="vertify_code" @blur="computedAge()" class="lf-color-999 lf-font-28 lf-text-left" style="position:absolute;right:180rpx" placeholder="请输入身份证号码"/>
  20. </view>
  21. <view class="cu-bar1 padding-lr" v-if="goods_type!=3">
  22. <text class="lf-color-555 lf-font-28">性别</text>
  23. <input type="text" v-model="sex" disabled class="lf-color-999 lf-font-28 lf-text-left" style="position:absolute;right:180rpx" placeholder="请输入性别"/>
  24. </view>
  25. <view class="cu-bar1 padding-lr" v-if="goods_type!=3">
  26. <text class="lf-color-555 lf-font-28">年龄</text>
  27. <input type="number" v-model="age" disabled class="lf-color-999 lf-font-28 lf-text-left" style="position:absolute;right:180rpx" placeholder="请输入年龄"/>
  28. </view>
  29. </view>
  30. <self-line/>
  31. <view class="lf-bg-white lf-p-t-30 lf-p-b-30 lf-p-l-32 lf-p-r-32">
  32. <view class="lf-row-between">
  33. <image :src="goods_details.picture" mode="aspectFill" style="width: 240rpx; height: 240rpx;border-radius: 20rpx;"></image>
  34. <view class="flex-sub padding-left-sm">
  35. <view class="bref-box lf-font-32 lf-color-333 lf-line-2" style="height: 88rpx;line-height: 44rpx;">
  36. {{goods_details.title}}
  37. </view>
  38. <view class="flex lf-m-t-25 align-center text-center">
  39. <text class="block lf-color-gray lf-font-24" style="line-height: 40rpx;">数量</text>
  40. <text class="lf-m-l-10 lf-color-gray lf-font-24">x {{goods_details.num}}</text>
  41. </view>
  42. <view class="flex align-center text-center lf-m-t-25">
  43. <lf-price :price="goods_details.price" />
  44. <view class="lf-m-l-20 lf-line-through lf-color-gray">
  45. {{goods_details.original_price}}
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. <!-- <self-line/>
  52. <view class="bg-white">
  53. <view class="cu-bar padding-lr">
  54. <text class="lf-color-555 lf-font-28">优惠</text>
  55. <view v-if="goods_details.coupon != ''">
  56. <text class="lf-color-price lf-font-28 lf-m-l-10" v-for="(item,index) of goods_details.coupon">{{item.tag}}</text>
  57. </view>
  58. <view v-else>
  59. <text class="lf-color-price lf-font-28 lf-m-l-10">暂无优惠</text>
  60. </view>
  61. </view>
  62. </view> -->
  63. <self-line/>
  64. <view class="bg-white" v-if="enter_type!=1">
  65. <!-- 酒店 -->
  66. <view v-if="goods_type == 1">
  67. <view class="cu-bar padding-lr">
  68. <text class="lf-color-555 lf-font-28">套餐类型</text>
  69. <text class="lf-font-28" style="color: #131315;">{{goods_typetext}}</text>
  70. </view>
  71. <view class="cu-bar padding-lr">
  72. <text class="lf-color-555 lf-font-28">酒店住房日期</text>
  73. <text class="lf-font-28" style="color: #131315;">{{check_in_time}}-{{check_out_time}} {{totalLive}}</text>
  74. </view>
  75. <view class="cu-bar padding-lr">
  76. <text class="lf-color-555 lf-font-28">到店时间</text>
  77. <text class="lf-font-28" style="color: #131315;">{{arrival_time}}</text>
  78. </view>
  79. </view>
  80. <!-- 景区 -->
  81. <view v-if="goods_type == 2">
  82. <view class="cu-bar padding-lr">
  83. <text class="lf-color-555 lf-font-28">套餐类型</text>
  84. <text class="lf-font-28" style="color: #131315;">{{goods_typetext}}</text>
  85. </view>
  86. <view class="cu-bar padding-lr">
  87. <text class="lf-color-555 lf-font-28">开始时间</text>
  88. <text class="lf-font-28" style="color: #131315;">{{enter_time}}</text>
  89. </view>
  90. </view>
  91. <!-- 旅游路线 -->
  92. <view v-if="goods_type == 0">
  93. <view class="cu-bar padding-lr">
  94. <text class="lf-color-555 lf-font-28">套餐类型</text>
  95. <text class="lf-font-28" style="color: #131315;">{{goods_typetext}}</text>
  96. </view>
  97. <view class="cu-bar padding-lr">
  98. <text class="lf-color-555 lf-font-28">开始时间</text>
  99. <text class="lf-font-28" style="color: #131315;">{{departure_time}}</text>
  100. </view>
  101. </view>
  102. </view>
  103. <self-line/>
  104. <view class="bg-white" v-if="enter_type!=1">
  105. <view class="lf-p-t-30 lf-p-l-32 lf-p-b-36">
  106. <view class="lf-font-28 lf-color-555">支付方式</view>
  107. </view>
  108. <view class="lf-p-r-32 lf-p-l-32">
  109. <button class="cu-btn bg-white margin-self" :class="pay_type==0?'border-green':'border'" @tap="payStatus(0)">
  110. <text class="lf-iconfont lf-icon-weixin text-green lf-font-44 lf-m-r-23"></text>
  111. <text class="lf-font-32" :class="pay_type==0?'text-green':'lf-color-333'">微信支付</text>
  112. <text class="lf-iconfont lf-icon-dui lf-font-44 lf-color-primary" v-if="pay_type==0" style="position: absolute;right: 22rpx;"></text>
  113. </button>
  114. </view>
  115. <view class="lf-p-r-32 lf-p-l-32 lf-m-t-30">
  116. <button class="cu-btn bg-white margin-self" :class="pay_type==1?'border-green':'border'" @tap="payStatus(1)">
  117. <text class="lf-font-32" :class="pay_type==1?'text-green':'lf-color-333'">线下支付</text>
  118. <text class="lf-iconfont lf-icon-dui lf-font-44 lf-color-primary" v-if="pay_type==1" style="position: absolute;right: 22rpx;"></text>
  119. </button>
  120. </view>
  121. <view class="lf-p-r-32 lf-p-l-32 lf-m-t-30" v-if="goods_details.deposit != '0.00'">
  122. <button class="cu-btn bg-white margin-self" :class="pay_type==2?'border-green':'border'" @tap="payStatus(2)">
  123. <text class="lf-font-32" :class="pay_type==2?'text-green':'lf-color-333'">订金支付</text>
  124. <text class="lf-iconfont lf-icon-dui lf-font-44 lf-color-primary" v-if="pay_type==2" style="position: absolute;right: 22rpx;"></text>
  125. </button>
  126. </view>
  127. <view class="lf-p-r-32 lf-p-l-32 lf-m-t-30">
  128. <button class="cu-btn bg-white margin-self" v-if="goods_details.earnest != '0.00'" :class="pay_type==3?'border-green':'border'" @tap="payStatus(3)">
  129. <text class="lf-font-32" :class="pay_type==3?'text-green':'lf-color-333'">定金支付</text>
  130. <text class="lf-iconfont lf-icon-dui lf-font-44 lf-color-primary" v-if="pay_type==3" style="position: absolute;right: 22rpx;"></text>
  131. </button>
  132. </view>
  133. <!-- <view class="lf-p-r-32 lf-p-l-32 lf-m-t-30">
  134. <button class="cu-btn bg-white margin-self" :class="pay_type==4?'border-green':'border'" @tap="payStatus(4)">
  135. <text class="lf-font-32" :class="pay_type==4?'text-green':'lf-color-333'">首款支付</text>
  136. <text class="lf-iconfont lf-icon-dui lf-font-44 lf-color-primary" v-if="pay_type==4" style="position: absolute;right: 22rpx;"></text>
  137. </button>
  138. </view> -->
  139. </view>
  140. <view style="height: 200rpx;"></view>
  141. <view class="btn-bottom solid-top1">
  142. <view class="padding-lr lf-p-t-10 lf-p-b-10 bg-white flex justify-between align-center shadow">
  143. <view class="flex align-center">
  144. <text class="lf-font-24 lf-font-555">应付款</text>
  145. <lf-price :price="goods_details.final_price" />
  146. </view>
  147. <button class="btn" @tap="submit">
  148. <text class="lf-font-32 text-white" v-if="btn_type == 1">下单付款</text>
  149. <text class="lf-font-32 text-white" v-else>支付尾款</text>
  150. </button>
  151. </view>
  152. </view>
  153. </view>
  154. </template>
  155. <script>
  156. export default {
  157. data() {
  158. return {
  159. goods_id: 0,
  160. goods_details: {},
  161. contact: '',
  162. phone: '',
  163. pay_type: 0,
  164. btn_type: 1,
  165. ifPay: true,
  166. order_id: 0,
  167. enter_type: 0,
  168. payState: true,
  169. pay_order_id: 0,
  170. vertify_code: '',
  171. sex: '',
  172. age: '',
  173. goods_type: 0,
  174. spec_id: 0,
  175. goods_typetext: '',
  176. //景区
  177. enter_time: '',
  178. //旅游路线
  179. departure_time: '',
  180. return_time: '',
  181. //酒店
  182. check_in_time: '',
  183. check_out_time: '',
  184. arrival_time: '',
  185. totalLive: ''
  186. }
  187. },
  188. onLoad(e) {
  189. //0旅游路线1酒店2景区3餐厅
  190. this.goods_id = e.goods_id;
  191. this.goods_type = e.goods_type;
  192. this.btn_type = e.btn_type;
  193. this.order_id = e.order_id;
  194. this.spec_id = e.spec_id;
  195. this.enter_type = e.enter_type;
  196. this.goods_typetext = e.goods_typetext;
  197. if(this.goods_id) {
  198. this.getGoodsData(this.pay_type);
  199. if(this.goods_type == 2) {
  200. this.enter_time = e.enter_time;
  201. }else if(this.goods_type == 0) {
  202. this.departure_time = e.departure_time;
  203. }else if(this.goods_type == 1) {
  204. this.check_in_time = e.check_in_time;
  205. this.check_out_time = e.check_out_time;
  206. this.arrival_time = e.arrival_time;
  207. this.totalLive = e.totalLive;
  208. console.log(this.check_in_time,this.check_out_time,this.arrival_time)
  209. }
  210. }
  211. if(this.order_id && this.enter_type == 1) {
  212. console.log('con列表执行')
  213. this.payOnce()
  214. }
  215. },
  216. onShow(e) {
  217. let that = this
  218. uni.$on('payState',(data) => {
  219. that.payState = data.msg;
  220. that.pay_order_id = data.payorder_id;
  221. console.log('传来的订单id',that.pay_order_id)
  222. if(that.payState == true) {
  223. that.$url('/pages/payState/paystate?ifSuccess=1&order_id='+that.pay_order_id,{type: 'redirect'})
  224. }else {
  225. that.$url('/pages/payState/paystate?ifSuccess=2&order_id='+that.pay_order_id,{type: 'redirect'})
  226. }
  227. })
  228. },
  229. onUnload() {
  230. uni.$off('payState');
  231. },
  232. methods: {
  233. computedAge() {
  234. this.$check(this.vertify_code,'card');
  235. let judge_sex = this.vertify_code[16];
  236. let judge_birthday = this.vertify_code.substring(6,14);
  237. let now_date = new Date();
  238. let now_date1 = this.$shared.recordTime(now_date, '-', 'date').replace(/-/g, "");
  239. let age1 = now_date1-judge_birthday;
  240. this.age = JSON.stringify(age1).substring(0,2)
  241. if(judge_sex%2) {
  242. this.sex = '男';
  243. }else {
  244. this.sex = '女';
  245. }
  246. },
  247. getPhoneNumber(event){
  248. if(event.detail.errMsg == 'getPhoneNumber:ok'){
  249. let encryptedData = event.detail.encryptedData;
  250. let iv = event.detail.iv;
  251. this.$http(this.API.API_WECHAT_SETPHONE, {
  252. encryptedData,
  253. iv,
  254. // token: userInfo.token // 已在公共参数传
  255. }).then(res => {
  256. this.phone = res.data.mobile;
  257. })
  258. }
  259. },
  260. payStatus(type) {
  261. if(type == this.pay_type) {
  262. this.pay_type = type;
  263. return
  264. }else {
  265. this.pay_type = type;
  266. this.getGoodsData(type);
  267. }
  268. },
  269. getGoodsData(type){
  270. this.$http(this.API.API_CONFIRMDETAILS,{id: this.goods_id,num: 1,pay_type: type}).then(res => {
  271. this.goods_details = res.data;
  272. console.log('数据',res)
  273. })
  274. },
  275. submit() {
  276. if(this.order_id && this.enter_type == 1) {
  277. this.payOnce()
  278. return
  279. }
  280. if(!this.contact) {
  281. this.$msg('请输入联系人!');
  282. return;
  283. }
  284. if(!this.phone) {
  285. this.$msg('请输入联系电话!');
  286. return;
  287. }
  288. if(this.goods_type != 3) {
  289. if(!this.vertify_code) {
  290. this.$msg('请输入身份证号!');
  291. return;
  292. }
  293. if(!this.sex) {
  294. this.$msg('请输入性别!');
  295. return;
  296. }
  297. if(!this.age) {
  298. this.$msg('请输入年龄!');
  299. return;
  300. }
  301. }
  302. if(!this.ifPay) return;
  303. this.ifPay = false;
  304. this.$http(this.API.API_CREATEORDER,{
  305. id: this.goods_id,
  306. num: 1,
  307. pay_type: this.pay_type,
  308. name:this.contact,
  309. mobile:this.phone,
  310. spec_id: this.spec_id,
  311. enter_time: this.enter_time,
  312. sex: this.sex,
  313. age: this.age,
  314. id_card: this.vertify_code,
  315. departure_time: this.departure_time,
  316. return_time: this.return_time,
  317. check_in_time: this.check_in_time,
  318. check_out_time: this.check_out_time,
  319. arrival_time: this.arrival_time
  320. }).then(res => {
  321. this.pay_order_id = res.data.id
  322. if(this.pay_type == 1) {
  323. this.ifPay = true
  324. this.$url('/pages/payState/paystate?ifSuccess=1&order_id='+res.data.id,{type: 'redirect'})
  325. }else if(res.data.jump == true) {
  326. let that = this;
  327. wx.navigateToMiniProgram({
  328. appId: res.data.jump_appid,
  329. path: '/pages/order/confirm_atonce',
  330. envVersion: 'release',
  331. extraData: {
  332. order_id: res.data.id
  333. },
  334. success(res) {
  335. console.log('---res---');
  336. that.ifPay = true;
  337. console.log(res);
  338. },
  339. fail(err) {
  340. console.log('---err---');
  341. console.log(err);
  342. that.ifPay = true;
  343. }
  344. })
  345. }
  346. }).catch(err => {
  347. this.ifPay = true
  348. })
  349. },
  350. payOnce() {
  351. this.$http(this.API.API_ORDERPAY,{id: this.order_id}).then(res => {
  352. if(res.data.jump) {
  353. wx.navigateToMiniProgram({
  354. appId: res.data.jump_appid,
  355. path: '/pages/order/confirm_atonce',
  356. envVersion: 'release',
  357. extraData: {
  358. order_id: res.data.id
  359. },
  360. success(res) {
  361. console.log('---res---')
  362. console.log(res)
  363. },
  364. fail(err) {
  365. console.log('---err---')
  366. console.log(err)
  367. }
  368. })
  369. }
  370. }).catch(err => {})
  371. }
  372. }
  373. }
  374. </script>
  375. <style scoped lang="scss">
  376. .cu-bar1 {
  377. display: flex;
  378. position: relative;
  379. align-items: center;
  380. min-height: 100rpx;
  381. }
  382. .btn{
  383. margin: 0;
  384. padding: 0;
  385. width: 212rpx;
  386. height: 82rpx;
  387. background-color: #1998FE;
  388. color: #FFFFFF;
  389. line-height: 80rpx;
  390. font-size: 32rpx;
  391. border-radius: 41rpx;
  392. }
  393. .bref-box {
  394. text-overflow: -o-ellipsis-lastline;
  395. overflow: hidden;
  396. text-overflow: ellipsis;
  397. display: -webkit-box;
  398. -webkit-line-clamp: 2;
  399. -webkit-box-orient: vertical;
  400. }
  401. </style>