index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  1. <template>
  2. <view class="container">
  3. <!-- 收货地址 -->
  4. <view class="address" v-if="!Data.ojsType || Data.ojsType ==1">
  5. <block v-if="DefaultAddress != '' && DefaultAddress.name !='' && DefaultAddress.name != undefined">
  6. <view class="add_head flex_r flex_ac flex_jb">
  7. <view class="user_info flex_r flex_ac">
  8. <view class="user_name">{{DefaultAddress.name}}</view>
  9. <view class="user_phone">{{DefaultAddress.mobile}}</view>
  10. </view>
  11. <view class="set_address flex_r flex_ac" @tap="chooseWXaddress">
  12. <image class="set_img" src="/static/img/setAddress.png" mode=""></image>
  13. <view class="set_text">修改</view>
  14. </view>
  15. </view>
  16. <view class="add_name mar_t20">{{DefaultAddress.address}}</view>
  17. </block>
  18. <block v-else>
  19. <view class="add_address flex_c flex_ac flex_jc" @tap="chooseWXaddress('add')">
  20. <image class="add_icon" src="/static/img/add.png" mode=""></image>
  21. <view class="add_text">添加收货地址</view>
  22. </view>
  23. </block>
  24. </view>
  25. <!-- 收货地址-end -->
  26. <!-- 商品信息 -->
  27. <view class="goods_info mar_t20">
  28. <view class="info_type">{{modularName}}</view>
  29. <view class="goods flex_r">
  30. <image class="goods_img" :src="goodsInfo.original_img" mode=""></image>
  31. <view class="goods_con flex_c flex_jc flex_jb">
  32. <view class="goods_name ellipsis2">{{goodsInfo.goods_name}}</view>
  33. <view class="flex_r flex_ac flex_jb">
  34. <view class="goods_msg">{{Data.type == 2 ? goodsInfo.trade_num + '消费积分' + '¥' + goodsInfo.trade_price : '¥' + goodsInfo.cost_price}}</view>
  35. <view class="goods_num">x {{Data.num}}</view>
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. <!-- 商品信息-end -->
  41. <!-- 订单信息 -->
  42. <view class="order mar_t20">
  43. <view class="order_list flex_r flex_ac flex_jb">
  44. <view class="list_name flex_r flex_jb"><text>数</text><text>量</text></view>
  45. <view class="list_con">{{Data.num}}</view>
  46. </view>
  47. <view class="order_list flex_r flex_ac flex_jb">
  48. <view class="flex_r flex_ac">
  49. <view class="list_name flex_r flex_jb"><text>运</text><text>费</text></view>
  50. <view class="list_con p_color">({{freight}}元/每套)</view>
  51. </view>
  52. <view class="list_con">¥{{freight}}</view>
  53. </view>
  54. <view class="order_list flex_r flex_ac flex_jb" v-if="Data.type == 2">
  55. <view class="flex_r flex_ac">
  56. <view class="list_name flex_r flex_jb"><text>茶</text><text>宝</text></view>
  57. <view class="list_con p_color">(可用{{userinfo.cha_bao}})</view>
  58. </view>
  59. <view class="list_con">{{basicsInfo.goodsTeaInt}}茶宝</view>
  60. </view>
  61. <view class="order_list flex_r flex_ac flex_jb" v-if="Data.type == 2">
  62. <view class="flex_r flex_ac">
  63. <view class="list_name flex_r flex_jb"><text>批</text><text>发</text><text>积</text><text>分</text></view>
  64. <view class="list_con p_color">(可用{{basicsInfo.integral}})</view>
  65. </view>
  66. <view class="list_con">{{basicsInfo.goodsPfInt}}批发积分</view>
  67. </view>
  68. <view class="order_list flex_r flex_ac flex_jb" v-if="Data.type != 5">
  69. <view class="list_name flex_r flex_jb"><text>商</text><text>品</text><text>金</text><text>额</text></view>
  70. <view class="list_con">¥{{Data.type == 2 ? goodsInfo.trade_price : goodsInfo.cost_price}}</view>
  71. </view>
  72. <view class="order_list flex_r flex_ac flex_jb" v-if="Data.type == 5">
  73. <view class="list_name flex_r flex_jb"><text>消</text><text>费</text><text>积</text><text>分</text></view>
  74. <view class="list_con">{{basicsInfo.stayPay}}消费积分</view>
  75. </view>
  76. <view class="order_list flex_r flex_ac flex_jb" v-if="Data.type == 5">
  77. <view class="list_name flex_r flex_jb"><text>可</text><text>用</text><text>积</text><text>分</text></view>
  78. <view class="list_con">{{userinfo.integral}}消费积分</view>
  79. </view>
  80. <view class="order_list flex_r flex_ac flex_jb">
  81. <view class="list_name flex_r flex_jb"><text>可</text><text>用</text><text>余</text><text>额</text></view>
  82. <view class="list_con p_color">¥{{userinfo.user_money}}</view>
  83. </view>
  84. </view>
  85. <!-- 订单信息-end -->
  86. <!-- 底部操作栏 -->
  87. <view class="bar flex_r flex_ac flex_jb">
  88. <view class="bar_info flex_r flex_ac">待支付<text>¥{{obligation}}</text></view>
  89. <view class="pay_btn flex_r flex_ac flex_jc" @tap="payment">立即支付</view>
  90. </view>
  91. <!-- 底部操作栏-end -->
  92. <!-- 收获地址弹窗 -->
  93. <userAddress ref="userAddress" @addressConfirm="loadDa" />
  94. </view>
  95. </template>
  96. <script>
  97. let page = 1;
  98. let app = getApp();
  99. var appEv = app.$vm.$options;
  100. import { get, post, u_post } from "@/request/api.js";
  101. import { ToPayOpre } from "@/utils/reqTools.js";
  102. let toPayOpre = new ToPayOpre();
  103. import userAddress from "pages/xghc-addrress/userAddress"
  104. export default {
  105. data() {
  106. return {
  107. Data: {},
  108. goodsInfo: '', // 商品信息
  109. modularName: '', // 商品类型
  110. DefaultAddress: '', // 用户默认地址
  111. basicsInfo: '', // 订单信息
  112. freight: 0, //运费
  113. userinfo: {},
  114. obligation: 0, //待支付
  115. };
  116. },
  117. components: {
  118. userAddress,
  119. },
  120. onLoad(e) {
  121. this.Data = e
  122. this.loadData(e);
  123. this.loadAddress();
  124. this.userinfo = uni.getStorageSync('userinfo');
  125. // 1零售 2批发 3精品 4今日值买
  126. this.modularName = e.type == 1 ? "零售专区" : e.type == 2 ? "批发专区" : e.type == 3 ? "精品专区" : "今日值买"
  127. },
  128. mounted() {
  129. // this.$refs.popup.open('top');
  130. },
  131. methods: {
  132. loadData(da) {
  133. post("goods/goodsDetail", da).then(res => {
  134. if (res.code === 0) {
  135. this.goodsInfo = res.data.data
  136. post("goods/freight", { type: da.type }).then(res => {
  137. if (res.code === 0) {
  138. this.freight = res.data.freight;
  139. }
  140. // 计算待支付
  141. let a = (this.goodsInfo.cost_price * this.Data.num + parseFloat(this.freight)) * 100;
  142. let b = (a - this.userinfo.user_money * 100) / 100;
  143. this.obligation = b > 0 ? b : 0
  144. })
  145. }
  146. })
  147. },
  148. // 获取用户地址
  149. loadAddress() {
  150. post("user/addressList").then(res => {
  151. if (res.code === 0) {
  152. let da = res.data.data;
  153. for (const i of da) {
  154. if (i.status == 1) {
  155. this.DefaultAddress = i;
  156. break;
  157. } else this.DefaultAddress = da[0]
  158. }
  159. }
  160. })
  161. },
  162. chooseWXaddress(va) {
  163. let a = va != "add" ? this.DefaultAddress.id : 'add'
  164. this.$refs.userAddress.open(a);
  165. // this.goto("/pages/xghc-addrress/userAddress");
  166. },
  167. // 支付
  168. payment: function() {
  169. // #ifdef  H5
  170. let type = "H5";
  171. // #endif
  172. // #ifdef  APP
  173. let type = "app";
  174. // #endif
  175. // #ifdef  MP-WEIXIN
  176. let type = "jsapi";
  177. // #endif
  178. if (!this.DefaultAddress.id) {
  179. appEv.errTips('请选择地址')
  180. return
  181. }
  182. post('goods/submitOrder', {
  183. ...this.Data,
  184. address_id: this.DefaultAddress.id,
  185. trade_type: type
  186. }).then(res => {
  187. if (res.code === 0) {
  188. toPayOpre.toPay(res.data, (rea) => {
  189. if (!rea) {
  190. // 支付成功
  191. appEv.errTips('支付成功')
  192. uni.switchTab({
  193. url: "/pages/szw-order-list/index",
  194. });
  195. } else {
  196. // 支付失败
  197. appEv.errTips('支付已取消')
  198. }
  199. });
  200. }
  201. })
  202. },
  203. loadDa(da) {
  204. this.DefaultAddress = da;
  205. }
  206. }
  207. }
  208. </script>
  209. <style lang="scss">
  210. // 页面配置
  211. page {
  212. background: #f5f5f5;
  213. }
  214. .container {
  215. padding: 20rpx;
  216. box-sizing: border-box;
  217. }
  218. // 页面配置-end
  219. // 收货地址
  220. .user_phone {
  221. font-size: 26rpx;
  222. color: #222;
  223. }
  224. .set_text {
  225. font-size: 24rpx;
  226. color: #868686;
  227. }
  228. .set_img {
  229. width: 24rpx;
  230. height: 24rpx;
  231. margin-right: 9rpx;
  232. }
  233. .add_address {
  234. width: 100%;
  235. overflow: hidden;
  236. height: 109rpx;
  237. }
  238. .add_icon {
  239. width: 60rpx;
  240. height: 60rpx;
  241. margin-bottom: 12rpx;
  242. }
  243. .user_name {
  244. font-size: 32rpx;
  245. color: #000;
  246. margin-right: 46rpx;
  247. }
  248. .add_name {
  249. width: 448rpx;
  250. overflow: hidden;
  251. font-size: 24rpx;
  252. color: #868686;
  253. }
  254. .add_text {
  255. font-size: 24rpx;
  256. color: #868686;
  257. font-family: "SourceHanSansCN-Normal";
  258. }
  259. .address {
  260. width: 100%;
  261. overflow: hidden;
  262. padding: 28rpx;
  263. box-sizing: border-box;
  264. background: #fff;
  265. border-radius: 12rpx;
  266. }
  267. // 收货地址-end
  268. // 商品信息
  269. .goods:nth-last-child(1) {
  270. margin-bottom: 0;
  271. }
  272. .goods_num {
  273. font-size: 26rpx;
  274. color: #989898;
  275. }
  276. .goods_con {
  277. width: calc(100% - 202rpx - 36rpx);
  278. overflow: hidden;
  279. }
  280. .goods {
  281. width: 100%;
  282. overflow: hidden;
  283. margin-bottom: 20rpx;
  284. align-items: initial;
  285. }
  286. .goods_img {
  287. width: 202rpx;
  288. height: 140rpx;
  289. margin-right: 36rpx;
  290. border-radius: 12rpx;
  291. }
  292. .goods_name {
  293. font-size: 34rpx;
  294. color: #1B1B1B;
  295. font-family: "SourceHanSansCN-Bold";
  296. font-weight: bold;
  297. }
  298. .goods_msg {
  299. overflow: hidden;
  300. font-size: 26rpx;
  301. color: #18BB88;
  302. font-family: 'SourceHanSansCN-Medium';
  303. font-weight: 500;
  304. }
  305. .info_type {
  306. font-size: 30rpx;
  307. color: #353535;
  308. font-family: "SourceHanSansCN-Bold";
  309. font-weight: bold;
  310. margin-bottom: 43rpx;
  311. }
  312. .goods_info {
  313. width: 100%;
  314. overflow: hidden;
  315. padding: 28rpx;
  316. background: #fff;
  317. border-radius: 12rpx;
  318. box-sizing: border-box;
  319. }
  320. // 商品信息-end
  321. // 订单信息
  322. .list_name {
  323. width: 102rpx;
  324. }
  325. .order_list:nth-last-child(1) {
  326. margin-bottom: 0;
  327. }
  328. .order_list {
  329. width: 100%;
  330. overflow: hidden;
  331. margin-bottom: 30rpx;
  332. }
  333. .list_con {
  334. font-size: 24rpx;
  335. color: #000;
  336. font-family: "SourceHanSansCN-Medium";
  337. font-weight: bold;
  338. line-height: 1;
  339. }
  340. .order {
  341. width: 100%;
  342. overflow: hidden;
  343. padding: 28rpx;
  344. box-sizing: border-box;
  345. background: #fff;
  346. border-radius: 12rpx;
  347. }
  348. .list_name text {
  349. font-size: 26rpx;
  350. color: rgba(0, 0, 0, .8);
  351. font-family: "SourceHanSansCN-Medium";
  352. font-weight: bold;
  353. line-height: 1;
  354. }
  355. .p_color {
  356. color: #FF6D44;
  357. }
  358. // 订单信息-end
  359. // 底部操作栏
  360. .bar_info {
  361. font-size: 24rpx;
  362. color: #000;
  363. font-family: "SourceHanSansCN-Medium";
  364. font-weight: bold;
  365. }
  366. .bar_info text {
  367. font-size: 30rpx;
  368. color: #FF6D44;
  369. font-family: "SourceHanSansCN-Medium";
  370. font-weight: bold;
  371. }
  372. .pay_btn {
  373. width: 187rpx;
  374. height: 72rpx;
  375. font-size: 30rpx;
  376. font-family: "SourceHanSansCN-Medium";
  377. font-weight: bold;
  378. background: #2DB48A;
  379. border-radius: 36rpx;
  380. color: #fff;
  381. }
  382. .bar {
  383. width: 100%;
  384. overflow: hidden;
  385. position: fixed;
  386. bottom: 0;
  387. left: 0;
  388. background: #fff;
  389. box-shadow: 0 0 10rpx rgba(0, 0, 0, .15);
  390. padding: 14rpx 30rpx;
  391. box-sizing: border-box;
  392. }
  393. // 底部操作栏-end
  394. </style>