order_confirm.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. {extend name="public/container"}
  2. {block name="title"}提交订单{/block}
  3. {block name="head_top"}
  4. <style>
  5. body {
  6. padding-bottom: 1.12rem;
  7. background-color: #f5f5f5;
  8. }
  9. </style>
  10. {/block}
  11. {block name="content"}
  12. <div v-cloak id="app">
  13. <div class="order-confirm">
  14. <div class="contact" @click="addressCheck">
  15. <div>
  16. <template v-if="addressChecked">
  17. <template v-for="item in address">
  18. <template v-if="item.id === addressChecked">
  19. <div :key="item.id">
  20. <span>{{ item.real_name }}</span>
  21. <span>{{ item.phone }}</span>
  22. </div>
  23. <div class="address">
  24. <span>[默认]</span>
  25. <span>{{ item.province }}{{ item.city }}{{ item.district }}{{ item.detail }}</span>
  26. </div>
  27. </template>
  28. </template>
  29. </template>
  30. <template v-else>选择收货地址</template>
  31. </div>
  32. <div class="knowledge iconxiangyou"></div>
  33. </div>
  34. <div class="panel">
  35. <div v-for="(item, index) in cartInfo" :key="index" class="goods">
  36. <div class="image">
  37. <img class="img" :src="item.productInfo.image">
  38. </div>
  39. <div class="text">
  40. <div class="name">{{ item.productInfo.store_name }}</div>
  41. <div class="group">
  42. <div class="money">
  43. <div class="price">¥
  44. <span v-if="level">{{ item.productInfo.vip_price }}</span>
  45. <span v-else>{{ item.productInfo.price }}</span>
  46. </div>
  47. </div>
  48. <div class="spinner">
  49. <button type="button" :disabled="number == 1" @click="number--">-</button>
  50. <input v-model.number="number" :value="item.cart_num" readonly>
  51. <button type="button" :disabled="number == item.productInfo.stock"
  52. @click="number++">+</button>
  53. </div>
  54. </div>
  55. </div>
  56. </div>
  57. <div class="postage">
  58. <div class="name">邮费</div>
  59. <div class="value">{{ postage }}</div>
  60. </div>
  61. <div class="remark">
  62. <div class="name">备注信息</div>
  63. <textarea class="textarea" v-model="signs.mark" rows="4" placeholder="选填备注信息"></textarea>
  64. </div>
  65. </div>
  66. <div class="footer">
  67. <div class="text">共{{ number }}件,合计:<div class="money"><span>¥</span>{{ total }}</div>
  68. </div>
  69. <button type="button" @click="pay">立即结算</button>
  70. </div>
  71. <div :class="{ mask: popupShow }" @click="popupShow = false"></div>
  72. <!-- 地址弹窗 -->
  73. <div class="popup" :class="{ on: popupShow }">
  74. <button type="button" @click="popupShow = false"></button>
  75. <div class="head">选择地址</div>
  76. <div class="cont">
  77. <label v-for="item in address" :key="item.id">
  78. <input v-model="addressChecked" :value="item.id" type="radio" name="address" hidden>
  79. <div>
  80. <div>{{ item.real_name }} {{ item.phone }}</div>
  81. <div>{{ item.province }}{{ item.city }}{{ item.district }}{{ item.detail }}</div>
  82. </div>
  83. </label>
  84. </div>
  85. <div class="foot">
  86. <a :href="$h.U({c:'my',a:'edit_address'})+'?cartId='+cartId">选择其他地址</a>
  87. </div>
  88. </div>
  89. <payment @change="changeVal" :payment="payment" :signs="signs" :money="totals" :now_money="now_money" :isyue="isyue" :isAlipay="is_alipay" :special_id="addressChecked" :iswechat="isWechat" :pay_type_num="pay_type_num"></payment>
  90. <enter :appear="appear" :url="url" :site_name="site_name"></enter>
  91. <shortcut></shortcut>
  92. </div>
  93. </div>
  94. <script>
  95. var cartInfo = {$cartInfo},
  96. cartId = {$cartId},
  97. priceGroup = {$priceGroup},
  98. orderKey = '{$orderKey}',
  99. userInfo = {$userInfo},
  100. now_money={$now_money},
  101. is_yue={$is_yue ? 'true' : 'false'},
  102. site_name = '{$Auth_site_name}',
  103. isWechat={$isWechat ? 'true' : 'false'},
  104. is_alipay={$is_alipay ? 'true' : 'false'},
  105. level={$level ? 'true' : 'false'};
  106. require(['vue', 'store', 'helper', '{__WAP_PATH}zsff/js/payment.js', '{__WAP_PATH}zsff/js/enter.js', '{__WAP_PATH}zsff/js/shortcut.js'], function (Vue, api, $h) {
  107. var app = new Vue({
  108. el: '#app',
  109. data: {
  110. isWechat: isWechat,
  111. appear: true,
  112. url: isWechat ? $h.U({c:'index',a:'login'}):$h.U({c:'login',a:'phone_check'}),
  113. site_name: site_name,
  114. payment: true,
  115. pay_type_num: 40,
  116. pinkId: '',
  117. link_pay_uid: '',
  118. isyue: is_yue, //余额是否开启
  119. is_alipay: is_alipay, //支付宝是否开启
  120. now_money: now_money, //余额
  121. cartId: cartId,
  122. cartInfo: cartInfo,
  123. priceGroup: priceGroup,
  124. userInfo: userInfo,
  125. popupShow: false,
  126. number: 1,
  127. totalPrice: 0,
  128. address: [],
  129. addressChecked: 0,
  130. totals: 0,
  131. postages: 0,
  132. signs:{
  133. key: orderKey,
  134. mark: ''
  135. }
  136. },
  137. computed: {
  138. total: function () {
  139. if (!this.cartInfo) {
  140. return;
  141. }
  142. var price = 0;
  143. if(level){
  144. price =this.cartInfo[0].productInfo.vip_price;
  145. }else{
  146. price =this.cartInfo[0].productInfo.price;
  147. }
  148. this.totals = $h.Mul(price, this.number);
  149. this.totals = $h.Add(this.totals, this.postages);
  150. return this.totals.toFixed(2);
  151. },
  152. postage: function () {
  153. if (!this.cartInfo) {
  154. return;
  155. }
  156. if (this.cartInfo[0].productInfo.is_postage || this.cartInfo[0].productInfo.free_shipping <= this.number) {
  157. this.postages = 0;
  158. return '包邮';
  159. }
  160. this.postages = this.cartInfo[0].productInfo.postage;
  161. return '¥' + this.postages;
  162. }
  163. },
  164. watch: {
  165. addressChecked: function () {
  166. this.popupShow = false;
  167. }
  168. },
  169. created: function () {
  170. this.getAddress();
  171. },
  172. mounted: function () {
  173. this.$nextTick(function () {
  174. });
  175. },
  176. methods: {
  177. getAddress: function () {
  178. $h.loadFFF();
  179. api.baseGet($h.U({ c: 'auth_api', a: 'user_address_list' }), function (res) {
  180. $h.loadClear();
  181. var data = res.data.data;
  182. this.address = data;
  183. var result = data.find(function (value) {
  184. return value.is_default;
  185. }.bind(this));
  186. if (result) {
  187. this.addressChecked = result.id;
  188. }
  189. }.bind(this), function (err) {
  190. $h.loadClear();
  191. console.error(err.data.msg);
  192. }.bind(this));
  193. },
  194. addressCheck: function () {
  195. if (this.address.length) {
  196. this.popupShow = true;
  197. } else {
  198. location.href = $h.U({ c: 'my', a: 'edit_address', p: { cartId: this.cartId } });
  199. }
  200. },
  201. getOrderPrice: function () {
  202. $h.loadFFF();
  203. api.baseGet($h.U({
  204. c: 'special',
  205. a: 'getOrderPrice',
  206. q: {
  207. cartId: this.cartId,
  208. cateNum: this.number,
  209. price: this.totals,
  210. postage: this.postages
  211. }
  212. }), function (res) {
  213. $h.loadClear();
  214. var data = res.data.data;
  215. this.signs.key = data.orderKey;
  216. this.priceGroup = data.priceGroup;
  217. this.payment = false;
  218. }.bind(this), function (err) {
  219. $h.loadClear();
  220. }.bind(this));
  221. },
  222. pay: function () {
  223. if (!this.addressChecked) {
  224. return $h.pushMsg('请选择收货地址');
  225. }
  226. $h.loadFFF();
  227. api.baseGet($h.U({ c: 'index', a: 'user_login' }), function (res) {
  228. $h.loadClear();
  229. this.getOrderPrice();
  230. }.bind(this), function (err) {
  231. $h.loadClear();
  232. this.appear = false;
  233. }.bind(this));
  234. },
  235. pay_order:function(data){
  236. this.orderId=data.result.orderId || '';
  237. switch (data.status){
  238. case "PAY_ERROR":case 'ORDER_EXIST':case 'ORDER_ERROR':
  239. this.extendOrder(data.msg);
  240. break;
  241. case 'WECHAT_PAY':
  242. this.wechatPay(data.result.jsConfig);
  243. break;
  244. case 'SUCCESS':
  245. this.successOrder(data.msg);
  246. break;
  247. case 'ZHIFUBAO_PAY':
  248. window.location.href=$h.U({c:'Alipay',a:'index',q:{info:data.result,params:'goods'}});
  249. break;
  250. }
  251. },
  252. wechatPay:function(config){
  253. var that = this;
  254. mapleWx($jssdk(),function(){
  255. this.chooseWXPay(config,function(){
  256. that.successOrder();
  257. },{
  258. fail:that.extendOrder,
  259. cancel:that.extendOrder
  260. });
  261. });
  262. },
  263. successOrder:function(msg){
  264. $h.showMsg({
  265. title:msg ? msg :'支付成功',
  266. icon:'success',
  267. success:function (){
  268. location.href = "{:url('wap/special/order_store_list')}?type=1";
  269. }
  270. });
  271. },
  272. extendOrder:function(msg){
  273. $h.showMsg({
  274. title: typeof msg == 'object' ? '支付失败' : msg,
  275. icon:'error',
  276. success:function (){
  277. location.href = "{:url('wap/special/order_store_list')}?type=0";
  278. }
  279. });
  280. },
  281. //关闭支付
  282. payClose:function(value){
  283. this.payment=value;
  284. },
  285. enter: function () {
  286. this.appear = false;
  287. },
  288. //关闭登录
  289. loginClose:function(value){
  290. this.appear=value;
  291. },
  292. //登录完成回调事件
  293. logComplete:function(){
  294. this.appear=true;
  295. },
  296. changeVal: function (opt) {
  297. if (typeof opt != 'object') opt = {};
  298. var action = opt.action || '';
  299. var value = opt.value || '';
  300. this[action] && this[action](value);
  301. }
  302. }
  303. });
  304. });
  305. </script>
  306. {/block}