index.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. {include file="public/head"}
  5. <link href="/system/frame/css/style.min.css?v=3.0.0" rel="stylesheet">
  6. <title>{$title|default=''}</title>
  7. <style>
  8. .flex {
  9. display: flex;
  10. justify-content: flex-start;
  11. align-items: center;
  12. }
  13. .no-shink {
  14. flex-shrink: 0;
  15. }
  16. .mar-l-10 {
  17. margin-left: 10px;
  18. }
  19. .mar-b-10 {
  20. margin-bottom: 10px;
  21. }
  22. .padd-15 {
  23. padding: 0 15px !important;
  24. }
  25. .shopBOx {
  26. margin: 15px 10px !important;
  27. }
  28. .alertBottom {
  29. position: fixed !important;
  30. bottom: 0;
  31. left: 0;
  32. padding-left: 30px !important;
  33. width: 100%;
  34. background-color: #ffffff;
  35. }
  36. .shopImg {
  37. width: 100px;
  38. height: 100px;
  39. }
  40. .clamp2 {
  41. overflow: hidden;
  42. text-overflow: ellipsis;
  43. display: -webkit-box;
  44. -webkit-line-clamp: 2;
  45. -webkit-box-orient: vertical;
  46. }
  47. .itemStart {
  48. align-items: flex-start;
  49. }
  50. .flexcontent {
  51. justify-content: center;
  52. }
  53. .text-cente {
  54. text-align: center
  55. }
  56. .demo-spin-icon-load {
  57. animation: ani-demo-spin 1s linear infinite;
  58. }
  59. @keyframes ani-demo-spin {
  60. from {
  61. transform: rotate(0deg);
  62. }
  63. 50% {
  64. transform: rotate(180deg);
  65. }
  66. to {
  67. transform: rotate(360deg);
  68. }
  69. }
  70. .demo-spin-col {
  71. height: 100px;
  72. position: relative;
  73. border: 1px solid #eee;
  74. }
  75. </style>
  76. </head>
  77. <body>
  78. <div class="wrapper wrapper-content">
  79. <div class="row">
  80. <div class="col-sm-12">
  81. <div class="ibox float-e-margins ">
  82. <div class="ibox-title">
  83. <h5>在线下单</h5>
  84. </div>
  85. <div id="store-attr" class="mp-form" v-cloak="">
  86. <Row class="searchBox padd-15 mar-b-10 mar-l-10" v-if="UserCard">
  87. <i-Col span="6">
  88. <div class="flex">
  89. <span class="no-shink">当前会员卡号:{{UserCard}} &nbsp; 会员余额:{{userData.now_money}}
  90. &nbsp; 消费券:{{userData.integral}} &nbsp; 手机号:{{userData.phone}}</span>
  91. </div>
  92. </i-Col>
  93. </Row>
  94. <Row class="searchBox padd-15" v-if="UserCard">
  95. <i-Col span="6">
  96. <div class="flex">
  97. <span class="no-shink mar-l-10">是否消费券:</span>
  98. <radio-group v-model="is_consumer" type="button">
  99. <Radio :label="1">是</Radio>
  100. <Radio :label="0">否</Radio>
  101. </radio-group>
  102. </div>
  103. </i-Col>
  104. <i-Col span="12">
  105. <div class="flex">
  106. <span class="no-shink mar-l-10">条形码:</span>
  107. <i-Input ref="code" placeholder="请扫描或输入条形码" @on-enter="getShopNum"
  108. v-model="shopId" type="text"></i-Input>
  109. <i-Button class="mar-l-10" type="primary" @click="getShopNum">添加商品</i-Button>
  110. </div>
  111. </i-Col>
  112. </Row>
  113. <Row class="searchBox padd-15" v-else>
  114. <i-Col span="8">
  115. <div class="flex">
  116. <span class="no-shink">会员卡号:</span>
  117. <i-Input ref="usercard" placeholder="请输入会员卡号" v-model="userCardInput"
  118. type="text" @on-enter="checkedUserCard"></i-Input>
  119. <i-Button class="mar-l-10" type="primary" @click="checkedUserCard">开始下单
  120. </i-Button>
  121. </div>
  122. </i-Col>
  123. </Row>
  124. <Row class="searchBox padd-15 shopBOx" v-if="UserCard">
  125. <i-Col span="24">
  126. <div>
  127. <h4 class="mar-b-10">当前商品信息</h4>
  128. <Row class="searchBox padd-15 mar-b-10 ">
  129. <i-Col span="8">
  130. <h4>商品信息</h4>
  131. </i-Col>
  132. <i-Col span="4">
  133. <h4 class="text-cente"> 商品单价</h4>
  134. </i-Col>
  135. <i-Col span="4">
  136. <h4 class="text-cente"> 商品总价</h4>
  137. </i-Col>
  138. <i-Col span="4">
  139. <h4 class="text-cente"> 商品类型</h4>
  140. </i-Col>
  141. <i-Col span="4">
  142. <h4 class="text-cente">
  143. 操作 </h4>
  144. </i-Col>
  145. </Row>
  146. <Row type="flex" align="middle" class="searchBox padd-15 mar-b-10"
  147. v-for="(ls,ind) in shopList" :key="ls.id">
  148. <i-Col span="8">
  149. <div class="flex itemStart">
  150. <img :src="ls.image" class="shopImg">
  151. <div class="titleBox mar-l-10">
  152. <div class="clamp2" :title="ls.name">{{ls.name}}</div>
  153. <div>
  154. 规格:{{ls.typeName}}
  155. </div>
  156. <div>
  157. 数量:{{+ls.num}}
  158. </div>
  159. </div>
  160. </div>
  161. </i-Col>
  162. <i-Col span="4" class="text-cente">
  163. {{ls.price}}
  164. </i-Col>
  165. <i-Col span="4" class="text-cente">
  166. {{domNum(ls.price*ls.num)}}
  167. </i-Col>
  168. <i-Col span="4" class="text-cente">
  169. {{+ls.is_consumer==0?'普通商品':'消费券商品'}}
  170. </i-Col>
  171. <i-Col span="4">
  172. <div class="flex flexcontent">
  173. <i-Button type="error" size="small" @click="delShop(ls,ind)">删除
  174. </i-Button>
  175. <i-Button class="mar-l-10" type="success" size="small"
  176. @click="changeNumShop(ls,1)">增加
  177. </i-Button>
  178. <i-Button class="mar-l-10" type="warning" size="small"
  179. @click="changeNumShop(ls,-1)">减少
  180. </i-Button>
  181. </div>
  182. </i-Col>
  183. </Row>
  184. </div>
  185. </i-Col>
  186. </Row>
  187. <Row class="searchBox padd-15 mar-b-10 alertBottom" v-if="UserCard">
  188. {eq name="type" value="0"}
  189. <i-Col span="6">
  190. <div class="flex">
  191. <span class="no-shink">选择商家:</span>
  192. <i-Select name="store_id" v-model="form.store_id" style="width: 80%" filterable>
  193. {volist name="store" id="v" }
  194. <i-Option value="{$v.id}">{$v.name}(id:{$v.id})</i-Option>
  195. {/volist}
  196. </i-Select>
  197. </div>
  198. </i-Col>
  199. {/eq}
  200. <i-Col span="6">
  201. <div class="flex">
  202. <span class="no-shink mar-l-10">支付方式:</span>
  203. <i-Select name="store_id" v-model="form.pay_type" default-label="微信"
  204. style="width: 80%" filterable>
  205. <!-- <i-Option value="alipay">支付宝</i-Option>-->
  206. <!-- <i-Option value="weixin">微信</i-Option>-->
  207. <i-Option value="jialie">嘉联支付</i-Option>
  208. -->
  209. <i-Option value="yue">余额</i-Option>
  210. <i-Option value="integral">消费券</i-Option>
  211. <!-- <i-Option value="consumer">消费券</i-Option>-->
  212. <i-Option value="offline">线下支付</i-Option>
  213. </i-Select>
  214. </div>
  215. </i-Col>
  216. <i-Col span="6" v-if="form.pay_type == 'offline'">
  217. <div class="flex">
  218. <span class="no-shink mar-l-10">线下支付方式:</span>
  219. <i-Select name="offline_type" v-model="form.offline_type" style="width: 80%" filterable>
  220. <i-Option value="0">现金</i-Option>
  221. <i-Option value="1">门店扫码</i-Option>
  222. <i-Option value="2">智慧8度积分</i-Option>
  223. <i-Option value="3">BTA支付</i-Option>
  224. </i-Select>
  225. </div>
  226. </i-Col>
  227. <i-Col span="6">
  228. <div class="flex">
  229. <span class="no-shink mar-l-10">当前金额:¥{{allPayMoney}}</span>
  230. <i-Button class="mar-l-10" type="success" @click="submit">确认下单</i-Button>
  231. </div>
  232. </i-Col>
  233. </Row>
  234. </div>
  235. </div>
  236. </div>
  237. </div>
  238. </div>
  239. <script>
  240. mpFrame.start(function(Vue) {
  241. new Vue({
  242. data: function() {
  243. return {
  244. form: {
  245. store_id: '{eq name="type" value="1"}{$store.0.id}{/eq}', //商家id
  246. pay_type: 'offline', //支付类型
  247. offline_type: '0' //支付类型
  248. },
  249. shopList: [], //当前选中的商品
  250. userCardInput: '', //用户输入内容
  251. UserCard: '', //当前选中的会员卡号
  252. userId: '', //当前选中的用户id
  253. userData: {}, //保存用户信息
  254. shopId: '', //当前商品条形码
  255. is_consumer: 0, //当前是否消费券
  256. lodingAddCart: false, //判断是否正在加入购物车
  257. }
  258. },
  259. mounted() {
  260. const that = this;
  261. //获取会员卡号焦点
  262. that.$nextTick(function() {
  263. that.$refs.usercard.focus();
  264. })
  265. },
  266. computed: {
  267. allPayMoney() {
  268. let money = 0;
  269. for (let i = 0; i < this.shopList.length; i++) {
  270. const item = this.shopList[i]
  271. money += item.price * item.num
  272. }
  273. return +(money.toFixed(2));
  274. }
  275. },
  276. methods: {
  277. // 向下取整舍弃数
  278. domNum: function(value) {
  279. return Math.floor(value*100)/100
  280. },
  281. // 修复订单
  282. async orderContrast() {
  283. // 开始处理数据
  284. const ind = layer.load(1,{
  285. shade: 0.1
  286. })
  287. const that = this;
  288. const userCart = (await $eb.axios.get('{:Url("lst")}' + '?uid=' + that.userId))
  289. .data.data.valid; //线上购物车商品
  290. const shopList = that.shopList; //本地购物车商品
  291. const errorCartList = []; //错误数据保存
  292. for (let i = 0; i < userCart.length; i++) {
  293. const uObj = userCart[i];
  294. for (let s = 0; s < shopList.length; s++) {
  295. const sObj = shopList[s];
  296. // 判断是否同一个商品
  297. if (uObj.cartId == sObj.cartId) {
  298. // 判断是否数据不对
  299. if (+uObj.cart_num < +sObj.num) {
  300. // 处理错误数据
  301. await that.changeCartShop(sObj.cartId, sObj.num)
  302. }
  303. break
  304. }
  305. }
  306. }
  307. layer.alert('修复成功')
  308. layer.close(ind);
  309. },
  310. //选中用户卡号
  311. checkedUserCard(e) {
  312. const that = this;
  313. // layer.msg('加载中请稍等。。。', {
  314. // icon: 16
  315. // ,shade: 0.01
  316. // });
  317. layer.load(1,{
  318. shade: 0.1
  319. })
  320. if (that.userCardInput.length == 12 || that.userCardInput.length == 15 || that
  321. .userCardInput.length == 8 || that.userCardInput.length == 11 || that
  322. .userCardInput == '1') {
  323. //初始化用户数据
  324. that.userId = '';
  325. that.userData = {}
  326. //请求获取用户信息
  327. $eb.axios.post('{:Url("getCardNo")}' + '?card_no=' + that.userCardInput).then(
  328. function(res) {
  329. console.log(res)
  330. const data = res.data;
  331. if (data.status == 200) {
  332. that.UserCard = that.userCardInput;
  333. that.userId = data.data.uid;
  334. that.userData = data.data.user
  335. that.delCartAll()
  336. } else {
  337. layer.closeAll('loading');
  338. layer.msg(data.msg, {
  339. icon: 5
  340. });
  341. }
  342. }).catch(function(err) {
  343. layer.closeAll('loading');
  344. console.log(err);
  345. })
  346. //设置获取焦点
  347. } else {
  348. layer.closeAll('loading');
  349. layer.msg('请输入8位,12位,17位卡号会员卡号,或输入1', {
  350. icon: 5
  351. });
  352. }
  353. },
  354. //删除购物车商品
  355. delShop(ls, ind) {
  356. const that = this;
  357. //询问框
  358. layer.confirm('是否删除当前商品?', {
  359. btn: ['是', '否'] //按钮
  360. }, function(index) {
  361. layer.close(index);
  362. //删除数组数据
  363. that.shopList.splice(ind, 1);
  364. //重新获取焦点
  365. that.$refs.code.focus();
  366. //删除购物车数据
  367. that.delCartShop([ls.cartId])
  368. layer.msg('删除成功!', {
  369. icon: 1
  370. });
  371. }, function(index) {
  372. layer.close(index);
  373. });
  374. },
  375. // 清空购物车
  376. delCartAll() {
  377. const that = this;
  378. $eb.axios.post('{:Url("clear_cart")}', {
  379. uid: that.userId
  380. }).then(function(res) {
  381. that.$nextTick(function() {
  382. that.$refs.code.focus();
  383. })
  384. layer.closeAll('loading');
  385. console.log(res, '购物车清空成功')
  386. }).catch(function(err) {
  387. that.delCartAll();
  388. console.log(err);
  389. })
  390. },
  391. //删除购物车数据
  392. delCartShop(ids) {
  393. const that = this;
  394. $eb.axios.post('{:Url("del")}', {
  395. ids: ids,
  396. uid: that.userId
  397. }).then(function(res) {
  398. console.log(res, '购物车删除成功')
  399. }).catch(function(err) {
  400. console.log(err);
  401. })
  402. },
  403. //增加减少数量
  404. changeNumShop(item, type) {
  405. const that = this;
  406. layer.prompt({
  407. title: '请输入需要' + (type > 0 ? '添加' : '减少') + '的数量',
  408. formType: 0
  409. }, function(pass, index) {
  410. layer.close(index);
  411. const nt = /^[0-9]*$/g; //匹配数字
  412. if (!nt.test(pass)) {
  413. console.log(nt.test(pass), '判断是否正确');
  414. layer.msg('请输入数字')
  415. return false
  416. }
  417. console.log(pass);
  418. if ((item.num * 1) + (pass * type) > 0) {
  419. //修改商品数量
  420. that.changeCartShop(item.cartId, (item.num * 1) + pass * type).then(
  421. function(data) {
  422. console.log(data.data.status);
  423. if (data.data.status == 200) {
  424. item.num = ((item.num * 1) + pass * type).toFixed(3);
  425. layer.msg('成功' + (type > 0 ? '添加' : '减少') + pass +
  426. '件商品')
  427. } else {
  428. layer.msg(data.data.msg);
  429. }
  430. }).catch(function(data) {
  431. console.log(data.data.status);
  432. layer.msg(data.data.msg);
  433. })
  434. } else {
  435. layer.msg('商品数量不可小于0')
  436. }
  437. });
  438. },
  439. //处理扫码加入商品时间
  440. async getShopNum() {
  441. const that = this;
  442. if (that.lodingAddCart) {
  443. that.shopId = '';
  444. iView.Message.warning('扫码速度过快,加入失败')
  445. return
  446. }
  447. that.lodingAddCart = true;
  448. layer.load(1,{
  449. shade: 0.1
  450. })
  451. await that.isShopNum();
  452. that.lodingAddCart = false;
  453. layer.closeAll('loading');
  454. // 处理设置允许获得焦点
  455. that.$nextTick(function() {
  456. that.$refs.code.focus();
  457. console.log('成功');
  458. })
  459. },
  460. //查询商品是否有库存
  461. isShopNum() {
  462. const that = this;
  463. let num = 0;
  464. let orderId = 0;
  465. if (that.shopId.length == 13 && that.shopId.substr(0, 2) == '20') {
  466. orderId = that.shopId.substr(2, 5);
  467. num = (Math.floor(that.shopId.substr(7, 6) / 10) / 1000).toFixed(3);
  468. } else {
  469. orderId = that.shopId;
  470. num = 1
  471. }
  472. that.shopId = '';
  473. return new Promise((resolve, reject) => {
  474. $eb.axios.post('{:Url("getBarCode")}' + (orderId ? '?bar_code=' +
  475. orderId : ''))
  476. .then(function(res) {
  477. // console.log(res);
  478. const data = res.data.data;
  479. // console.log(data, '返回数据')
  480. if (that.is_consumer != data.is_consumer) {
  481. if (that.is_consumer == 1) {
  482. layer.msg('请选择消费券商品', {
  483. icon: 5
  484. })
  485. }
  486. if (that.is_consumer == 0) {
  487. layer.msg('请选择普通商品', {
  488. icon: 5
  489. })
  490. }
  491. resolve()
  492. } else {
  493. //添加到购物车
  494. that.addCart(data, num).then(() => {
  495. console.log('购物车加入成功');
  496. resolve()
  497. }).catch((err) => {
  498. console.log('购物车加入失败');
  499. reject()
  500. })
  501. }
  502. }).catch(function(err) {
  503. reject(err)
  504. console.log(err);
  505. })
  506. })
  507. },
  508. //添加购物车
  509. addCart(product, num = 1) {
  510. const that = this
  511. console.log('开始添加购物车');
  512. let pushData = {
  513. productId: product.product_id, //普通产品编号
  514. uid: this.userId,
  515. uniqueId: product.unique, //属性唯一值
  516. cartNum: num, //购物车数量
  517. new: 0, // 1 加入购物车直接购买 0 加入购物车
  518. }
  519. return new Promise((resolve, reject) => {
  520. $eb.axios.post('{:Url("add_cart")}', pushData).then(function(res) {
  521. console.log(res)
  522. const data = res.data;
  523. if (data.status == 200) {
  524. //保存购物车id
  525. const cartId = data.data.cartId
  526. //判断是否有这个商品
  527. const ind = that.shopList.findIndex(function(a) {
  528. if (a.cartId == cartId) {
  529. return true
  530. } else {
  531. return false
  532. }
  533. })
  534. //判断这个商品是否已经存在数组
  535. if (ind > -1) {
  536. that.shopList[ind].num = (+that.shopList[ind].num + (
  537. +num)).toFixed(3);
  538. resolve(true)
  539. } else {
  540. //初始化商品
  541. that.initShopData(product, cartId, (+num).toFixed(3))
  542. .then((data) => {
  543. resolve(true)
  544. }).catch((err) => {
  545. reject(err);
  546. })
  547. }
  548. } else {
  549. layer.msg(data.msg, {
  550. icon: 5
  551. });
  552. reject(data)
  553. }
  554. }).catch(function(err) {
  555. reject(err)
  556. console.log(err);
  557. })
  558. })
  559. },
  560. //初始化购物车商品
  561. initShopData(product, cartId, num) {
  562. const that = this;
  563. return new Promise((resolve, rejact) => {
  564. that.shopList = ([{
  565. name: product.store_name, //商品
  566. num: num, //购物车中的数量
  567. id: product.product_id, //当前商品id
  568. cartId: cartId, //保存购物车id
  569. typeName: product.suk, //商品规格名称
  570. unique: product.unique, //商品规格id
  571. image: product.image, //商品主图
  572. price: product.price, //商品价格
  573. is_consumer: product.is_consumer //商品类型
  574. }]).concat(that.shopList);
  575. // console.log(this, '初始化后this对象')
  576. //初始化该商品为1
  577. that.changeCartShop(cartId, num).then((data) => {
  578. resolve(data);
  579. }).catch((err) => {
  580. rejact(err);
  581. })
  582. })
  583. },
  584. //修改购物车物品数量
  585. changeCartShop(cartId, num) {
  586. const that = this;
  587. return new Promise(function(ok, erro) {
  588. $eb.axios.post('{:Url("num")}', {
  589. id: cartId,
  590. number: num,
  591. uid: that.userId
  592. }).then(function(res) {
  593. console.log(ok)
  594. ok(res)
  595. }).catch(function(err) {
  596. layer.msg('购物车加入失败请刷新页面', {
  597. icon: 5
  598. })
  599. erro(err)
  600. console.log(err);
  601. })
  602. })
  603. },
  604. submit: async function() {
  605. let confirmData;
  606. let that = this;
  607. // console.log(that.form.store_id, '当前门店id')
  608. //当前门店
  609. if (!that.form.store_id) {
  610. return layer.msg('请选择门店', {
  611. icon: 5
  612. });
  613. }
  614. if (!that.shopList.length > 0) {
  615. return layer.msg('请选择商品', {
  616. icon: 5
  617. });
  618. }
  619. //用于保存当前选中的商品cardid
  620. let pusharr = []
  621. for (let i = 0; i < that.shopList.length; i++) {
  622. pusharr.push(that.shopList[i].cartId);
  623. }
  624. layer.load(1,{
  625. shade: 0.1
  626. })
  627. //提交订单
  628. try {
  629. //提交数据
  630. let pushData = {
  631. cartId: pusharr.join(','),
  632. uid: that.userId
  633. }
  634. let res = await $eb.axios.post('{:Url("confirm")}', pushData);
  635. confirmData = res.data
  636. const orderKey = res.data.data.orderKey;
  637. let money = await that.computedOrder(orderKey);
  638. layer.closeAll('loading');
  639. layer.confirm('订单总金额:¥' + that.allPayMoney.toFixed(2) + '<br/> vip优惠:¥' + ((
  640. that.allPayMoney - money.pay_price) > 0 ? (
  641. that.allPayMoney - money.pay_price).toFixed(
  642. 2) : 0) + '<br/> 实际支付:¥' + money.pay_price
  643. .toFixed(2), {
  644. btn: ['立即支付', '取消', '修复订单','查看数据'], //按钮
  645. yes: async function(index) {
  646. layer.close(index);
  647. try {
  648. //微信
  649. // if (that.form.pay_type == 'weixin') {
  650. // let qr = await that.weixinPay();
  651. // that.create(orderKey, qr)
  652. // }
  653. // 余额
  654. if (that.form.pay_type == 'yue') {
  655. that.create(orderKey)
  656. }
  657. //现金
  658. if (that.form.pay_type == 'offline') {
  659. that.create(orderKey)
  660. }
  661. // 积分
  662. if (that.form.pay_type == 'integral') {
  663. that.create(orderKey)
  664. }
  665. //支付宝
  666. // if (that.form.pay_type == 'alipay') {
  667. // that.create(orderKey)
  668. // }
  669. if (that.form.pay_type == 'jialie') {
  670. let qr = await that.jialiePay();
  671. that.create(orderKey, qr)
  672. }
  673. } catch (e) {
  674. console.log(e);
  675. }
  676. },
  677. btn2: function(index) {
  678. layer.close(index);
  679. },
  680. btn3: function(index) {
  681. console.log('对比');
  682. that.orderContrast();
  683. },
  684. btn4: function(index) {
  685. console.log('对比2');
  686. layer.close(index);
  687. layer.alert(`错误返回数据${JSON.stringify(confirmData)}`, {icon: 0});
  688. },
  689. });
  690. console.log(money, '金额计算');
  691. } catch (e) {
  692. layer.closeAll('loading');
  693. layer.msg(e.message, {
  694. icon: 5
  695. });
  696. layer.alert(`错误返回数据${JSON.stringify(confirmData)}`, {icon: 0});
  697. console.log(e)
  698. }
  699. },
  700. weixinPay() {
  701. return new Promise(function(ok, err) {
  702. layer.prompt({
  703. title: '请输入微信付款码编号',
  704. formType: 0
  705. }, function(pass, index) {
  706. layer.close(index);
  707. ok(pass)
  708. });
  709. })
  710. },
  711. //嘉联支付验证
  712. jialiePay() {
  713. return new Promise(function(ok, err) {
  714. layer.prompt({
  715. title: '请输入付款码编号',
  716. formType: 0
  717. }, function(pass, index) {
  718. layer.close(index);
  719. ok(pass)
  720. });
  721. })
  722. },
  723. //计算订单价格
  724. computedOrder(key) {
  725. const that = this;
  726. return new Promise(function(ok, erro) {
  727. $eb.axios.post('{:Url("computedOrder")}', {
  728. key,
  729. uid: that.userId,
  730. offline_type:that.form.offline_type
  731. }).then(function(res) {
  732. //保存订单key
  733. ok(res.data.data.result)
  734. }).catch(function(err) {
  735. erro(err)
  736. })
  737. })
  738. },
  739. //创建订单
  740. create(key, qr) {
  741. let that = this;
  742. let data = {
  743. key: key,
  744. uid: that.userId,
  745. shipping_type: 2,
  746. store_id: that.form.store_id,
  747. real_name: that.userData.nickname,
  748. phone: that.userData.phone,
  749. offline_type:that.form.offline_type,
  750. payType: that.form.pay_type //支付方式
  751. };
  752. //判断是否需要传入code码
  753. if (qr) {
  754. data.auth_code = qr;
  755. }
  756. //提交订单
  757. $eb.axios.post('{:Url("create")}', data).then(function(res) {
  758. layer.confirm(res.data.msg + '<br/>' + '是否刷新?', {
  759. btn: ['刷新', '取消'] //按钮
  760. }, function(index) {
  761. //清除用户卡号信息
  762. that.UserCard = '';
  763. window.location.reload();
  764. //parent.$(".J_iframe:visible")[0].contentWindow.location.reload();
  765. layer.close(index);
  766. }, function(index) {
  767. layer.close(index);
  768. });
  769. console.log(res)
  770. }).catch(function(err) {
  771. })
  772. }
  773. },
  774. }).$mount(document.getElementById('store-attr'))
  775. })
  776. </script>