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

409 lines
14 KiB

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