海南旅游项目 前端仓库
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.

426 lines
14 KiB

4 years ago
4 years ago
4 years ago
5 years ago
5 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
5 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 || goods_type == 4 || goods_type == 5">
  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. hotel_specid: []
  187. }
  188. },
  189. onLoad(e) {
  190. //0旅游路线1酒店2景区3餐厅
  191. this.goods_id = e.goods_id;
  192. this.goods_type = e.goods_type;
  193. this.btn_type = e.btn_type;
  194. this.order_id = e.order_id;
  195. if(this.goods_type == 1) {
  196. var arr = e.spec_id.split(",")
  197. console.log(arr)
  198. this.hotel_specid = arr
  199. console.log('数组id',this.hotel_specid)
  200. }else {
  201. this.spec_id = e.spec_id;
  202. }
  203. this.enter_type = e.enter_type;
  204. this.goods_typetext = e.goods_typetext;
  205. if(this.goods_id) {
  206. this.getGoodsData(this.pay_type);
  207. if(this.goods_type == 2) {
  208. this.enter_time = e.enter_time;
  209. }else if(this.goods_type == 0 || this.goods_type == 4 || this.goods_type == 5) {
  210. this.departure_time = e.departure_time;
  211. }else if(this.goods_type == 1) {
  212. this.check_in_time = e.check_in_time;
  213. this.check_out_time = e.check_out_time;
  214. this.arrival_time = e.arrival_time;
  215. this.totalLive = e.totalLive;
  216. console.log(this.check_in_time,this.check_out_time,this.arrival_time)
  217. }
  218. }
  219. if(this.order_id && this.enter_type == 1) {
  220. console.log('con列表执行')
  221. this.payOnce()
  222. }
  223. },
  224. onShow(e) {
  225. let that = this
  226. uni.$on('payState',(data) => {
  227. that.payState = data.msg;
  228. that.pay_order_id = data.payorder_id;
  229. console.log('传来的订单id',that.pay_order_id)
  230. if(that.payState == true) {
  231. that.$url('/pages/payState/paystate?ifSuccess=1&order_id='+that.pay_order_id,{type: 'redirect'})
  232. }else {
  233. that.$url('/pages/payState/paystate?ifSuccess=2&order_id='+that.pay_order_id,{type: 'redirect'})
  234. }
  235. })
  236. },
  237. onUnload() {
  238. uni.$off('payState');
  239. },
  240. methods: {
  241. computedAge() {
  242. this.$check(this.vertify_code,'card');
  243. let judge_sex = this.vertify_code[16];
  244. let judge_birthday = this.vertify_code.substring(6,14);
  245. let now_date = new Date();
  246. let now_date1 = this.$shared.recordTime(now_date, '-', 'date').replace(/-/g, "");
  247. let age1 = now_date1-judge_birthday;
  248. this.age = JSON.stringify(age1).substring(0,2)
  249. if(judge_sex%2) {
  250. this.sex = '男';
  251. }else {
  252. this.sex = '女';
  253. }
  254. if(this.vertify_code == '') {
  255. this.sex = '请输入身份证号码获取';
  256. this.age = '请输入身份证号码获取';
  257. }
  258. },
  259. getPhoneNumber(event){
  260. if(event.detail.errMsg == 'getPhoneNumber:ok'){
  261. let encryptedData = event.detail.encryptedData;
  262. let iv = event.detail.iv;
  263. this.$http(this.API.API_WECHAT_SETPHONE, {
  264. encryptedData,
  265. iv,
  266. // token: userInfo.token // 已在公共参数传
  267. }).then(res => {
  268. this.phone = res.data.mobile;
  269. })
  270. }
  271. },
  272. payStatus(type) {
  273. if(type == this.pay_type) {
  274. this.pay_type = type;
  275. return
  276. }else {
  277. this.pay_type = type;
  278. this.getGoodsData(type);
  279. }
  280. },
  281. getGoodsData(type){
  282. this.$http(this.API.API_CONFIRMDETAILS,{id: this.goods_id,num: 1,pay_type: type,spec_id: this.goods_type==1?this.hotel_specid:this.spec_id}).then(res => {
  283. this.goods_details = res.data;
  284. console.log('数据',res)
  285. })
  286. },
  287. submit() {
  288. if(this.order_id && this.enter_type == 1) {
  289. this.payOnce()
  290. return
  291. }
  292. if(!this.contact) {
  293. this.$msg('请输入联系人!');
  294. return;
  295. }
  296. if(!this.phone) {
  297. this.$msg('请输入联系电话!');
  298. return;
  299. }
  300. if(this.goods_type != 3) {
  301. if(!this.vertify_code) {
  302. this.$msg('请输入身份证号!');
  303. return;
  304. }
  305. if(!this.sex) {
  306. this.$msg('请输入性别!');
  307. return;
  308. }
  309. if(!this.age) {
  310. this.$msg('请输入年龄!');
  311. return;
  312. }
  313. }
  314. if(!this.ifPay) return;
  315. this.ifPay = false;
  316. this.$http(this.API.API_CREATEORDER,{
  317. id: this.goods_id,
  318. num: 1,
  319. pay_type: this.pay_type,
  320. name:this.contact,
  321. mobile:this.phone,
  322. spec_id: this.spec_id,
  323. enter_time: this.enter_time,
  324. sex: this.sex,
  325. age: this.age,
  326. id_card: this.vertify_code,
  327. departure_time: this.departure_time,
  328. return_time: this.return_time,
  329. check_in_time: this.check_in_time,
  330. check_out_time: this.check_out_time,
  331. arrival_time: this.arrival_time
  332. }).then(res => {
  333. this.pay_order_id = res.data.id
  334. if(this.pay_type == 1) {
  335. this.ifPay = true
  336. this.$url('/pages/payState/paystate?ifSuccess=1&order_id='+res.data.id,{type: 'redirect'})
  337. }else if(res.data.jump == true) {
  338. let that = this;
  339. wx.navigateToMiniProgram({
  340. appId: res.data.jump_appid,
  341. path: '/pages/order/confirm_atonce',
  342. envVersion: 'release',
  343. extraData: {
  344. order_id: res.data.id
  345. },
  346. success(res) {
  347. console.log('---res---');
  348. that.ifPay = true;
  349. console.log(res);
  350. },
  351. fail(err) {
  352. console.log('---err---');
  353. console.log(err);
  354. that.ifPay = true;
  355. }
  356. })
  357. }
  358. }).catch(err => {
  359. this.ifPay = true
  360. })
  361. },
  362. payOnce() {
  363. this.$http(this.API.API_ORDERPAY,{id: this.order_id}).then(res => {
  364. if(res.data.jump) {
  365. wx.navigateToMiniProgram({
  366. appId: res.data.jump_appid,
  367. path: '/pages/order/confirm_atonce',
  368. envVersion: 'release',
  369. extraData: {
  370. order_id: res.data.id
  371. },
  372. success(res) {
  373. console.log('---res---')
  374. console.log(res)
  375. },
  376. fail(err) {
  377. console.log('---err---')
  378. console.log(err)
  379. }
  380. })
  381. }
  382. }).catch(err => {})
  383. }
  384. }
  385. }
  386. </script>
  387. <style scoped lang="scss">
  388. .cu-bar1 {
  389. display: flex;
  390. position: relative;
  391. align-items: center;
  392. min-height: 100rpx;
  393. }
  394. .btn{
  395. margin: 0;
  396. padding: 0;
  397. width: 212rpx;
  398. height: 82rpx;
  399. background-color: #1998FE;
  400. color: #FFFFFF;
  401. line-height: 80rpx;
  402. font-size: 32rpx;
  403. border-radius: 41rpx;
  404. }
  405. .bref-box {
  406. text-overflow: -o-ellipsis-lastline;
  407. overflow: hidden;
  408. text-overflow: ellipsis;
  409. display: -webkit-box;
  410. -webkit-line-clamp: 2;
  411. -webkit-box-orient: vertical;
  412. }
  413. </style>