index.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801
  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-Select>
  224. </div>
  225. </i-Col>
  226. <i-Col span="6">
  227. <div class="flex">
  228. <span class="no-shink mar-l-10">当前金额:¥{{allPayMoney}}</span>
  229. <i-Button class="mar-l-10" type="success" @click="submit">确认下单</i-Button>
  230. </div>
  231. </i-Col>
  232. </Row>
  233. </div>
  234. </div>
  235. </div>
  236. </div>
  237. </div>
  238. <script>
  239. mpFrame.start(function(Vue) {
  240. new Vue({
  241. data: function() {
  242. return {
  243. form: {
  244. store_id: '{eq name="type" value="1"}{$store.0.id}{/eq}', //商家id
  245. pay_type: 'offline', //支付类型
  246. offline_type: '0' //支付类型
  247. },
  248. shopList: [], //当前选中的商品
  249. userCardInput: '', //用户输入内容
  250. UserCard: '', //当前选中的会员卡号
  251. userId: '', //当前选中的用户id
  252. userData: {}, //保存用户信息
  253. shopId: '', //当前商品条形码
  254. is_consumer: 0, //当前是否消费券
  255. lodingAddCart: false, //判断是否正在加入购物车
  256. }
  257. },
  258. mounted() {
  259. const that = this;
  260. //获取会员卡号焦点
  261. that.$nextTick(function() {
  262. that.$refs.usercard.focus();
  263. })
  264. },
  265. computed: {
  266. allPayMoney() {
  267. let money = 0;
  268. for (let i = 0; i < this.shopList.length; i++) {
  269. const item = this.shopList[i]
  270. money += item.price * item.num
  271. }
  272. return +(money.toFixed(2));
  273. }
  274. },
  275. methods: {
  276. // 向下取整舍弃数
  277. domNum: function(value) {
  278. return Math.floor(value*100)/100
  279. },
  280. // 修复订单
  281. async orderContrast() {
  282. // 开始处理数据
  283. const ind = layer.load(1,{
  284. shade: 0.1
  285. })
  286. const that = this;
  287. const userCart = (await $eb.axios.get('{:Url("lst")}' + '?uid=' + that.userId))
  288. .data.data.valid; //线上购物车商品
  289. const shopList = that.shopList; //本地购物车商品
  290. const errorCartList = []; //错误数据保存
  291. for (let i = 0; i < userCart.length; i++) {
  292. const uObj = userCart[i];
  293. for (let s = 0; s < shopList.length; s++) {
  294. const sObj = shopList[s];
  295. // 判断是否同一个商品
  296. if (uObj.cartId == sObj.cartId) {
  297. // 判断是否数据不对
  298. if (+uObj.cart_num < +sObj.num) {
  299. // 处理错误数据
  300. await that.changeCartShop(sObj.cartId, sObj.num)
  301. }
  302. break
  303. }
  304. }
  305. }
  306. layer.alert('修复成功')
  307. layer.close(ind);
  308. },
  309. //选中用户卡号
  310. checkedUserCard(e) {
  311. const that = this;
  312. // layer.msg('加载中请稍等。。。', {
  313. // icon: 16
  314. // ,shade: 0.01
  315. // });
  316. layer.load(1,{
  317. shade: 0.1
  318. })
  319. if (that.userCardInput.length == 12 || that.userCardInput.length == 15 || that
  320. .userCardInput.length == 8 || that.userCardInput.length == 11 || that
  321. .userCardInput == '1') {
  322. //初始化用户数据
  323. that.userId = '';
  324. that.userData = {}
  325. //请求获取用户信息
  326. $eb.axios.post('{:Url("getCardNo")}' + '?card_no=' + that.userCardInput).then(
  327. function(res) {
  328. console.log(res)
  329. const data = res.data;
  330. if (data.status == 200) {
  331. that.UserCard = that.userCardInput;
  332. that.userId = data.data.uid;
  333. that.userData = data.data.user
  334. that.delCartAll()
  335. } else {
  336. layer.closeAll('loading');
  337. layer.msg(data.msg, {
  338. icon: 5
  339. });
  340. }
  341. }).catch(function(err) {
  342. layer.closeAll('loading');
  343. console.log(err);
  344. })
  345. //设置获取焦点
  346. } else {
  347. layer.closeAll('loading');
  348. layer.msg('请输入8位,12位,17位卡号会员卡号,或输入1', {
  349. icon: 5
  350. });
  351. }
  352. },
  353. //删除购物车商品
  354. delShop(ls, ind) {
  355. const that = this;
  356. //询问框
  357. layer.confirm('是否删除当前商品?', {
  358. btn: ['是', '否'] //按钮
  359. }, function(index) {
  360. layer.close(index);
  361. //删除数组数据
  362. that.shopList.splice(ind, 1);
  363. //重新获取焦点
  364. that.$refs.code.focus();
  365. //删除购物车数据
  366. that.delCartShop([ls.cartId])
  367. layer.msg('删除成功!', {
  368. icon: 1
  369. });
  370. }, function(index) {
  371. layer.close(index);
  372. });
  373. },
  374. // 清空购物车
  375. delCartAll() {
  376. const that = this;
  377. $eb.axios.post('{:Url("clear_cart")}', {
  378. uid: that.userId
  379. }).then(function(res) {
  380. that.$nextTick(function() {
  381. that.$refs.code.focus();
  382. })
  383. layer.closeAll('loading');
  384. console.log(res, '购物车清空成功')
  385. }).catch(function(err) {
  386. that.delCartAll();
  387. console.log(err);
  388. })
  389. },
  390. //删除购物车数据
  391. delCartShop(ids) {
  392. const that = this;
  393. $eb.axios.post('{:Url("del")}', {
  394. ids: ids,
  395. uid: that.userId
  396. }).then(function(res) {
  397. console.log(res, '购物车删除成功')
  398. }).catch(function(err) {
  399. console.log(err);
  400. })
  401. },
  402. //增加减少数量
  403. changeNumShop(item, type) {
  404. const that = this;
  405. layer.prompt({
  406. title: '请输入需要' + (type > 0 ? '添加' : '减少') + '的数量',
  407. formType: 0
  408. }, function(pass, index) {
  409. layer.close(index);
  410. const nt = /^[0-9]*$/g; //匹配数字
  411. if (!nt.test(pass)) {
  412. console.log(nt.test(pass), '判断是否正确');
  413. layer.msg('请输入数字')
  414. return false
  415. }
  416. console.log(pass);
  417. if ((item.num * 1) + (pass * type) > 0) {
  418. //修改商品数量
  419. that.changeCartShop(item.cartId, (item.num * 1) + pass * type).then(
  420. function(data) {
  421. console.log(data.data.status);
  422. if (data.data.status == 200) {
  423. item.num = ((item.num * 1) + pass * type).toFixed(3);
  424. layer.msg('成功' + (type > 0 ? '添加' : '减少') + pass +
  425. '件商品')
  426. } else {
  427. layer.msg(data.data.msg);
  428. }
  429. }).catch(function(data) {
  430. console.log(data.data.status);
  431. layer.msg(data.data.msg);
  432. })
  433. } else {
  434. layer.msg('商品数量不可小于0')
  435. }
  436. });
  437. },
  438. //处理扫码加入商品时间
  439. async getShopNum() {
  440. const that = this;
  441. if (that.lodingAddCart) {
  442. that.shopId = '';
  443. iView.Message.warning('扫码速度过快,加入失败')
  444. return
  445. }
  446. that.lodingAddCart = true;
  447. layer.load(1,{
  448. shade: 0.1
  449. })
  450. await that.isShopNum();
  451. that.lodingAddCart = false;
  452. layer.closeAll('loading');
  453. // 处理设置允许获得焦点
  454. that.$nextTick(function() {
  455. that.$refs.code.focus();
  456. console.log('成功');
  457. })
  458. },
  459. //查询商品是否有库存
  460. isShopNum() {
  461. const that = this;
  462. let num = 0;
  463. let orderId = 0;
  464. if (that.shopId.length == 13 && that.shopId.substr(0, 2) == '20') {
  465. orderId = that.shopId.substr(2, 5);
  466. num = (Math.floor(that.shopId.substr(7, 6) / 10) / 1000).toFixed(3);
  467. } else {
  468. orderId = that.shopId;
  469. num = 1
  470. }
  471. that.shopId = '';
  472. return new Promise((resolve, reject) => {
  473. $eb.axios.post('{:Url("getBarCode")}' + (orderId ? '?bar_code=' +
  474. orderId : ''))
  475. .then(function(res) {
  476. // console.log(res);
  477. const data = res.data.data;
  478. // console.log(data, '返回数据')
  479. if (that.is_consumer != data.is_consumer) {
  480. if (that.is_consumer == 1) {
  481. layer.msg('请选择消费券商品', {
  482. icon: 5
  483. })
  484. }
  485. if (that.is_consumer == 0) {
  486. layer.msg('请选择普通商品', {
  487. icon: 5
  488. })
  489. }
  490. resolve()
  491. } else {
  492. //添加到购物车
  493. that.addCart(data, num).then(() => {
  494. console.log('购物车加入成功');
  495. resolve()
  496. }).catch((err) => {
  497. console.log('购物车加入失败');
  498. reject()
  499. })
  500. }
  501. }).catch(function(err) {
  502. reject(err)
  503. console.log(err);
  504. })
  505. })
  506. },
  507. //添加购物车
  508. addCart(product, num = 1) {
  509. const that = this
  510. console.log('开始添加购物车');
  511. let pushData = {
  512. productId: product.product_id, //普通产品编号
  513. uid: this.userId,
  514. uniqueId: product.unique, //属性唯一值
  515. cartNum: num, //购物车数量
  516. new: 0, // 1 加入购物车直接购买 0 加入购物车
  517. }
  518. return new Promise((resolve, reject) => {
  519. $eb.axios.post('{:Url("add_cart")}', pushData).then(function(res) {
  520. console.log(res)
  521. const data = res.data;
  522. if (data.status == 200) {
  523. //保存购物车id
  524. const cartId = data.data.cartId
  525. //判断是否有这个商品
  526. const ind = that.shopList.findIndex(function(a) {
  527. if (a.cartId == cartId) {
  528. return true
  529. } else {
  530. return false
  531. }
  532. })
  533. //判断这个商品是否已经存在数组
  534. if (ind > -1) {
  535. that.shopList[ind].num = (+that.shopList[ind].num + (
  536. +num)).toFixed(3);
  537. resolve(true)
  538. } else {
  539. //初始化商品
  540. that.initShopData(product, cartId, (+num).toFixed(3))
  541. .then((data) => {
  542. resolve(true)
  543. }).catch((err) => {
  544. reject(err);
  545. })
  546. }
  547. } else {
  548. layer.msg(data.msg, {
  549. icon: 5
  550. });
  551. reject(data)
  552. }
  553. }).catch(function(err) {
  554. reject(err)
  555. console.log(err);
  556. })
  557. })
  558. },
  559. //初始化购物车商品
  560. initShopData(product, cartId, num) {
  561. const that = this;
  562. return new Promise((resolve, rejact) => {
  563. that.shopList = ([{
  564. name: product.store_name, //商品
  565. num: num, //购物车中的数量
  566. id: product.product_id, //当前商品id
  567. cartId: cartId, //保存购物车id
  568. typeName: product.suk, //商品规格名称
  569. unique: product.unique, //商品规格id
  570. image: product.image, //商品主图
  571. price: product.price, //商品价格
  572. is_consumer: product.is_consumer //商品类型
  573. }]).concat(that.shopList);
  574. // console.log(this, '初始化后this对象')
  575. //初始化该商品为1
  576. that.changeCartShop(cartId, num).then((data) => {
  577. resolve(data);
  578. }).catch((err) => {
  579. rejact(err);
  580. })
  581. })
  582. },
  583. //修改购物车物品数量
  584. changeCartShop(cartId, num) {
  585. const that = this;
  586. return new Promise(function(ok, erro) {
  587. $eb.axios.post('{:Url("num")}', {
  588. id: cartId,
  589. number: num,
  590. uid: that.userId
  591. }).then(function(res) {
  592. console.log(ok)
  593. ok(res)
  594. }).catch(function(err) {
  595. layer.msg('购物车加入失败请刷新页面', {
  596. icon: 5
  597. })
  598. erro(err)
  599. console.log(err);
  600. })
  601. })
  602. },
  603. submit: async function() {
  604. let confirmData;
  605. let that = this;
  606. // console.log(that.form.store_id, '当前门店id')
  607. //当前门店
  608. if (!that.form.store_id) {
  609. return layer.msg('请选择门店', {
  610. icon: 5
  611. });
  612. }
  613. if (!that.shopList.length > 0) {
  614. return layer.msg('请选择商品', {
  615. icon: 5
  616. });
  617. }
  618. //用于保存当前选中的商品cardid
  619. let pusharr = []
  620. for (let i = 0; i < that.shopList.length; i++) {
  621. pusharr.push(that.shopList[i].cartId);
  622. }
  623. layer.load(1,{
  624. shade: 0.1
  625. })
  626. //提交订单
  627. try {
  628. //提交数据
  629. let pushData = {
  630. cartId: pusharr.join(','),
  631. uid: that.userId
  632. }
  633. let res = await $eb.axios.post('{:Url("confirm")}', pushData);
  634. confirmData = res.data
  635. const orderKey = res.data.data.orderKey;
  636. let money = await that.computedOrder(orderKey);
  637. layer.closeAll('loading');
  638. layer.confirm('订单总金额:¥' + that.allPayMoney.toFixed(2) + '<br/> vip优惠:¥' + ((
  639. that.allPayMoney - money.pay_price) > 0 ? (
  640. that.allPayMoney - money.pay_price).toFixed(
  641. 2) : 0) + '<br/> 实际支付:¥' + money.pay_price
  642. .toFixed(2), {
  643. btn: ['立即支付', '取消', '修复订单','查看数据'], //按钮
  644. yes: async function(index) {
  645. layer.close(index);
  646. try {
  647. //微信
  648. // if (that.form.pay_type == 'weixin') {
  649. // let qr = await that.weixinPay();
  650. // that.create(orderKey, qr)
  651. // }
  652. // 余额
  653. if (that.form.pay_type == 'yue') {
  654. that.create(orderKey)
  655. }
  656. //现金
  657. if (that.form.pay_type == 'offline') {
  658. that.create(orderKey)
  659. }
  660. // 积分
  661. if (that.form.pay_type == 'integral') {
  662. that.create(orderKey)
  663. }
  664. //支付宝
  665. // if (that.form.pay_type == 'alipay') {
  666. // that.create(orderKey)
  667. // }
  668. if (that.form.pay_type == 'jialie') {
  669. let qr = await that.jialiePay();
  670. that.create(orderKey, qr)
  671. }
  672. } catch (e) {
  673. console.log(e);
  674. }
  675. },
  676. btn2: function(index) {
  677. layer.close(index);
  678. },
  679. btn3: function(index) {
  680. console.log('对比');
  681. that.orderContrast();
  682. },
  683. btn4: function(index) {
  684. console.log('对比2');
  685. layer.close(index);
  686. layer.alert(`错误返回数据${JSON.stringify(confirmData)}`, {icon: 0});
  687. },
  688. });
  689. console.log(money, '金额计算');
  690. } catch (e) {
  691. layer.closeAll('loading');
  692. layer.msg(e.message, {
  693. icon: 5
  694. });
  695. layer.alert(`错误返回数据${JSON.stringify(confirmData)}`, {icon: 0});
  696. console.log(e)
  697. }
  698. },
  699. weixinPay() {
  700. return new Promise(function(ok, err) {
  701. layer.prompt({
  702. title: '请输入微信付款码编号',
  703. formType: 0
  704. }, function(pass, index) {
  705. layer.close(index);
  706. ok(pass)
  707. });
  708. })
  709. },
  710. //嘉联支付验证
  711. jialiePay() {
  712. return new Promise(function(ok, err) {
  713. layer.prompt({
  714. title: '请输入付款码编号',
  715. formType: 0
  716. }, function(pass, index) {
  717. layer.close(index);
  718. ok(pass)
  719. });
  720. })
  721. },
  722. //计算订单价格
  723. computedOrder(key) {
  724. const that = this;
  725. return new Promise(function(ok, erro) {
  726. $eb.axios.post('{:Url("computedOrder")}', {
  727. key,
  728. uid: that.userId,
  729. offline_type:that.form.offline_type
  730. }).then(function(res) {
  731. //保存订单key
  732. ok(res.data.data.result)
  733. }).catch(function(err) {
  734. erro(err)
  735. })
  736. })
  737. },
  738. //创建订单
  739. create(key, qr) {
  740. let that = this;
  741. let data = {
  742. key: key,
  743. uid: that.userId,
  744. shipping_type: 2,
  745. store_id: that.form.store_id,
  746. real_name: that.userData.nickname,
  747. phone: that.userData.phone,
  748. offline_type:that.form.offline_type,
  749. payType: that.form.pay_type //支付方式
  750. };
  751. //判断是否需要传入code码
  752. if (qr) {
  753. data.auth_code = qr;
  754. }
  755. //提交订单
  756. $eb.axios.post('{:Url("create")}', data).then(function(res) {
  757. layer.confirm(res.data.msg + '<br/>' + '是否刷新?', {
  758. btn: ['刷新', '取消'] //按钮
  759. }, function(index) {
  760. //清除用户卡号信息
  761. that.UserCard = '';
  762. window.location.reload();
  763. //parent.$(".J_iframe:visible")[0].contentWindow.location.reload();
  764. layer.close(index);
  765. }, function(index) {
  766. layer.close(index);
  767. });
  768. console.log(res)
  769. }).catch(function(err) {
  770. })
  771. }
  772. },
  773. }).$mount(document.getElementById('store-attr'))
  774. })
  775. </script>