confirm_order.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. <template>
  2. <div v-if="datas!==''">
  3. <div v-document_title>确认订单</div>
  4. <div class="check_order">
  5. <div @click="link_address">
  6. <flexbox style="background: #fff" v-if="datas.address !== null">
  7. <flexbox-item class="address_box"><span class="address_icon"></span></flexbox-item>
  8. <flexbox-item :span="4/5" style="padding: 24px 0;line-height: 50px;">
  9. <p>{{store_address?store_address.name:datas.address.true_name}}&nbsp;&nbsp;&nbsp;{{store_address?store_address.mobile:datas.address.mob_phone}}</p>
  10. <p>{{store_address?store_address.address:datas.address.area_info+datas.address.address}}</p>
  11. </flexbox-item>
  12. </flexbox>
  13. <div v-else>
  14. <p style="text-align: center;color:#EB4E4F; padding: 50px 0;background: #fff; font-size: 26px;">
  15. <icon type="warn"></icon>
  16. 请填写收货人信息
  17. </p>
  18. </div>
  19. </div>
  20. <group>
  21. <x-input title="红包支付" class="weui-vcode" style="padding-top: 21px; padding-bottom: 21px;">
  22. <p slot="left"></p>
  23. <icon slot="right" type="success-circle" style="color: #EB4E4F"></icon>
  24. </x-input>
  25. <x-input title="微信支付" class="weui-vcode" style="padding-top: 21px; padding-bottom: 21px;">
  26. <icon slot="right" type="success-circle" style="color: #EB4E4F"></icon>
  27. </x-input>
  28. </group>
  29. <flexbox style="margin-top: 0.71428571em;" v-for="goods in goods_list" :key="goods">
  30. <flexbox-item style="background: #fff; padding:30px;" class="vux-1px-b">
  31. <flexbox>
  32. <flexbox-item :span="2/6">
  33. <img :src="goods.goods_image_url" style="width: 175px;height: 175px;">
  34. </flexbox-item>
  35. <flexbox-item :span="3/6" style="padding-left: 25px;">
  36. <p>{{goods.goods_mobile_name}}</p>
  37. <p style="margin: 20px 0 40px 0;" class="letter_pro">{{goods.goods_spec}}</p>
  38. <p><span class="letter_warn" style="margin-right: 10px; font-size: 30px;">¥{{goods.act_type == 0?goods.bonus_price:goods.goods_promotion_price}}</span><span
  39. class="letter_pro">专柜价{{goods.goods_price}}</span></p>
  40. </flexbox-item>
  41. <flexbox-item style="text-align: right;">
  42. <span class="letter_pro">x{{goods.goods_num}}</span>
  43. </flexbox-item>
  44. </flexbox>
  45. </flexbox-item>
  46. </flexbox>
  47. <div style="background: #fff; padding:20px 0 20px 30px;" v-if="datas.payinfo.gap_desc"><span
  48. class="letter_pro">{{datas.payinfo.gap_desc}}</span></div>
  49. <div class="entry">
  50. <flexbox>
  51. <flexbox-item>
  52. <flexbox>
  53. <flexbox-item :span="4/5" style="line-height: 50px;">商品总价</flexbox-item>
  54. <flexbox-item :span="1/5" style="text-align: right"><span class="letter_warn">¥ {{datas.payinfo['goods_amount']}}</span>
  55. </flexbox-item>
  56. </flexbox>
  57. </flexbox-item>
  58. </flexbox>
  59. <flexbox>
  60. <flexbox-item>
  61. <flexbox>
  62. <flexbox-item :span="4/5" style="line-height: 50px;">{{datas.payinfo['full_desc']}}
  63. </flexbox-item>
  64. <flexbox-item :span="1/5" style="text-align: right" v-if="datas.payinfo['full_desc']"><span
  65. class="letter_info">- ¥ {{datas.payinfo['full_discount']}}</span></flexbox-item>
  66. </flexbox>
  67. </flexbox-item>
  68. </flexbox>
  69. <flexbox>
  70. <flexbox-item>
  71. <flexbox v-for="bonus in datas.payinfo['bonus_rates']" :key="bonus">
  72. <flexbox-item :span="4/5" style="line-height: 50px;"><span class="bonus_bg"><span
  73. class="bonus_rate">{{bonus.rate}}%</span></span>红包抵扣
  74. </flexbox-item>
  75. <flexbox-item :span="1/5" style="text-align: right"><span class="letter_info">- ¥ {{bonus.total}}</span>
  76. </flexbox-item>
  77. </flexbox>
  78. </flexbox-item>
  79. </flexbox>
  80. <flexbox>
  81. <flexbox-item>
  82. <flexbox>
  83. <flexbox-item :span="4/5" style="line-height: 50px;">运费</flexbox-item>
  84. <flexbox-item :span="1/5" style="text-align: right"><span class="letter_warn">+ ¥ {{datas.payinfo['freight']}}</span>
  85. </flexbox-item>
  86. </flexbox>
  87. </flexbox-item>
  88. </flexbox>
  89. </div>
  90. </div>
  91. <div class="order_pay">
  92. <div class="default_address" v-if="datas.address !== null">
  93. 配送至:{{store_address?store_address.address:datas.address.area_info+datas.address.address}}
  94. </div>
  95. <div class="just_buy">
  96. <flexbox>
  97. <flexbox-item :span="4/6" style="text-align: center;line-height: 93px; font-size: 30px;">应付: <span
  98. class="letter_warn">¥ {{datas.payinfo['pay_cash_pred']}}</span></flexbox-item>
  99. <flexbox-item :span="2/6"
  100. style="text-align: center;background:#EB4E4F;color: #fff;line-height: 93px; "><p
  101. @click="onBridgeReady">去付款</p></flexbox-item>
  102. </flexbox>
  103. </div>
  104. </div>
  105. </div>
  106. </template>
  107. <script>
  108. import {Flexbox, FlexboxItem, Group, CellBox, XSwitch, XInput, Icon} from 'vux'
  109. import Api from '../../lib/api'
  110. import Proxy from '../blocks/util/proxy'
  111. export default
  112. {
  113. created()
  114. {
  115. this.$store.commit('updateLoadingStatus', {isLoading: true});
  116. let goods_id = this.$route.query["goods_id"];
  117. let goods_num = this.$route.query['num'];
  118. let iscart = this.$route.query["iscart"];
  119. let cart_id = this.$route.query["cart_id"] ? this.$route.query["cart_id"] : '';
  120. this.$http.jsonp(Api.step_first(iscart, cart_id, goods_id, goods_num),{_timeout:5000}).then(function (res) {
  121. if (res.body.datas == null && res.body.code !== '200') {
  122. this.$vux.toast.show({
  123. type: 'warn',
  124. text: res.body.message,
  125. position: 'middle',
  126. width: '600px'
  127. });
  128. this.$router.go(-1);
  129. }
  130. else {
  131. this.datas = res.body['datas'];
  132. this.proxy.addData(res.body.datas);
  133. this.$store.commit('updateLoadingStatus', {isLoading: false});
  134. }
  135. },(err) => {
  136. this.$vux.toast.show({
  137. type: 'text',
  138. text: "网络错误",
  139. position: 'middle'
  140. })
  141. })
  142. },
  143. beforeDestroy(){
  144. this.$store.commit('update_address', {
  145. 'name': '',
  146. 'mobile': '',
  147. 'address': '',
  148. 'aid': ''
  149. });
  150. },
  151. data ()
  152. {
  153. return {
  154. datas: '',
  155. proxy: new Proxy(),
  156. aid: ''
  157. }
  158. },
  159. computed: {
  160. default_address(){
  161. let address_list = this.datas['address'];
  162. },
  163. goods_list(){
  164. if (!this.datas)return;
  165. let goods_list = this.datas.goods_list;
  166. let list = [];
  167. for (let i = 0; i < goods_list.length; i++) {
  168. let goods_item = this.proxy.getSummery(goods_list[i].goods_id);
  169. goods_item.goods_num = goods_list[i].goods_num;
  170. list.push(goods_item);
  171. }
  172. return list;
  173. },
  174. store_address(){
  175. let address;
  176. if (this.$store.state.address['name']) {
  177. address = this.$store.state.address;
  178. return address;
  179. }
  180. else {
  181. return false;
  182. }
  183. }
  184. },
  185. methods: {
  186. link_address(){
  187. this.$router.push({path: '/address/list', query: {need_goBack: true}});
  188. },
  189. onBridgeReady(){
  190. let goods_id = this.$route.query["goods_id"];
  191. let goods_num = this.$route.query['num'];
  192. let iscart = this.$route.query["iscart"];
  193. let cart_id = this.$route.query["cart_id"] ? this.$route.query["cart_id"] : '';
  194. let vat_hash = this.datas['payinfo'].vat_hash;
  195. let offpay_hash = this.datas['payinfo'].offpay_hash;
  196. let offpay_hash_batch = this.datas['payinfo'].offpay_hash_batch;
  197. let address_id = this.store_address ? this.store_address.aid : this.datas['address'].address_id;
  198. console.log(address_id);
  199. this.$http.jsonp(Api.step_second(cart_id, goods_id, goods_num, address_id, 0, vat_hash, offpay_hash, offpay_hash_batch),{_timeout:5000}).then(function (res) {
  200. if (res.status == 200 && res.body.code == 200) {
  201. let param = res.body.datas.param.data;
  202. WeixinJSBridge.invoke(
  203. 'getBrandWCPayRequest', {
  204. "appId": param.appId, //公众号名称,由商户传入
  205. "timeStamp": param.timeStamp, //时间戳,自1970年以来的秒数
  206. "nonceStr": param.nonceStr, //随机串
  207. "package": param.package,
  208. "signType": param.signType, //微信签名方式:
  209. "paySign": param.paySign //微信签名
  210. },
  211. function (res) {
  212. if (res.err_msg == "get_brand_wcpay_request:ok") {
  213. alert('支付成功');
  214. } // 使用以上方式判断前端返回,微信团队郑重提示:res.err_msg将在用户支付成功后返回 ok,但并不保证它绝对可靠。
  215. }
  216. );
  217. } else {
  218. let msg;
  219. if (res.status != 200) {
  220. msg = "网络错误!";
  221. } else {
  222. msg = res.body.message;
  223. }
  224. this.$vux.toast.show({
  225. type: 'text',
  226. text: msg,
  227. position: 'middle'
  228. });
  229. }
  230. },(err) => {
  231. this.$vux.toast.show({
  232. type: 'text',
  233. text: "网络错误",
  234. position: 'middle'
  235. })
  236. });
  237. }
  238. },
  239. components: {
  240. Flexbox,
  241. FlexboxItem,
  242. Group,
  243. CellBox,
  244. XSwitch,
  245. XInput,
  246. Icon
  247. }
  248. }
  249. </script>
  250. <style scoped>
  251. #router_view {
  252. background: #f9f9f9;
  253. }
  254. .address_box {
  255. padding: 24px 0 24px 40px;
  256. }
  257. .address_box p {
  258. line-height: 50px;
  259. }
  260. .address_icon {
  261. display: inline-block;
  262. width: 34px;
  263. height: 47px;
  264. background: url("../../assets/address_icon.jpg") no-repeat;
  265. background-size: 100% 100%;
  266. }
  267. .check_order {
  268. padding-bottom: 133px;
  269. }
  270. .entry {
  271. background: #fff;
  272. margin-top: 0.71428571em;
  273. padding: 30px;
  274. }
  275. .order_pay {
  276. position: fixed;
  277. bottom: 0;
  278. left: 0;
  279. width: 100%;
  280. }
  281. .just_buy {
  282. height: 93px;
  283. background: #fff;
  284. }
  285. .default_address {
  286. font-size: 18px;
  287. background: #ffeab8;
  288. color: #f2bc73;
  289. height: 40px;
  290. line-height: 40px;
  291. padding-left: 30px;
  292. }
  293. .bonus_bg {
  294. background: #f2bb11;
  295. padding: 5px;
  296. margin-right: 5px;
  297. }
  298. .bonus_rate {
  299. border: 1px dashed #fff;
  300. }
  301. .letter_pro {
  302. color: #a7a7a7;
  303. }
  304. .letter_info {
  305. color: #09BB07;
  306. }
  307. .letter_warn {
  308. color: #EB4E4F;
  309. }
  310. .weui-icon-warn {
  311. vertical-align: text-bottom;
  312. font-size: 34px;
  313. }
  314. </style>