时空网前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

292 lines
8.5 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. <template>
  2. <view>
  3. <!-- 商品信息 -->
  4. <block v-if="isRight(orderDetails)">
  5. <view class="bg-white padding-tb-sm">
  6. <skeleton :loading="skeletonLoading" :row="2" :showAvatar="false" :showTitle="true">
  7. <view class="flex justify-between align-start padding-top-sm padding-lr">
  8. <image :src="orderDetails.goods.cover" mode="aspectFill" style="width: 240rpx; height: 240rpx;border-radius: 10rpx;"></image>
  9. <view class="flex-sub padding-left-sm">
  10. <view class="bref-box lf-font-32 lf-font-bold" style="height: 88rpx;line-height: 44rpx;color: #222;">
  11. {{orderDetails.goods.name}}
  12. </view>
  13. <view class="flex justify-between align-center text-center">
  14. <text class="block margin-top-sm text-gray lf-font-28" style="margin-top: 20rpx;line-height: 40rpx;">数量</text>
  15. <view class="flex align-center margin-top-sm">
  16. <text class="lf-iconfont lf-icon-jianhao lf-font-40" style="color: #999;" @tap="reduce"></text>
  17. <input @blur="changeNum(num)" type="number" v-model="num" class="text-center margin-lr-sm radius text-black lf-font-32" style="width: 60rpx; height: 50rpx;background-color: #f1f1f1;color: #222;" />
  18. <text class="lf-iconfont lf-icon-jiahao lf-font-40" style="color: #999;" @tap="add"></text>
  19. </view>
  20. </view>
  21. <view class="flex justify-between margin-top-sm">
  22. <lf-price :price="orderDetails.goods.specs[0].selling_price" />
  23. <!-- <view class="text-red text-price lf-font-42 lf-font-bold" style="margin-top: 12rpx;">
  24. {{Number(orderDetails.goods.specs[0].selling_price || 0)}}
  25. </view> -->
  26. </view>
  27. </view>
  28. </view>
  29. </skeleton>
  30. </view>
  31. <self-line/>
  32. <skeleton :loading="skeletonLoading" :row="1" :showAvatar="false" :showTitle="true">
  33. <view class="bg-white">
  34. <view class="cu-bar padding-lr">
  35. <text class="text-gray lf-font-32">优惠</text>
  36. <text class="lf-font-32 text-black1">暂无优惠</text>
  37. </view>
  38. </view>
  39. </skeleton>
  40. <self-line/>
  41. <skeleton :loading="skeletonLoading" :row="13" :showAvatar="false" :showTitle="true">
  42. <view class="btn-bottom">
  43. <view class="padding flex justify-around align-center bg-gray1" v-if="orderDetails.agreement.title">
  44. <checkbox-group class="block" @change="CheckboxChange">
  45. <view class="margin-right">
  46. <checkbox @change="CheckboxChange" :class="checkbox[0].checked?'checked':''" :checked="checkbox[0].checked?true:false" value="A"></checkbox>
  47. </view>
  48. </checkbox-group>
  49. <view class="lf-font-24 text-gray">
  50. 请认真阅读并同意<text @tap="$routerGo('/pages/agreement/agreement?id='+orderDetails.agreement.article_id)" class="text-orange">{{orderDetails.agreement.title}}</text>在小程序下单购买即表示您已默认同意<text class="text-orange" @tap="$routerGo('/pages/agreement/agreement?id='+orderDetails.agreement.article_id)">{{orderDetails.agreement.title}}</text>的所有条款
  51. </view>
  52. </view>
  53. <view class="padding-lr padding-tb-sm bg-white flex justify-between align-center shadow">
  54. <view class="flex align-center">
  55. <text class="lf-font-28 text-gray">应付款</text>
  56. <lf-price :price="total(num, orderDetails.goods.specs[0].selling_price)" />
  57. <!-- <view class="text-red text-price lf-font-42 lf-font-bold">
  58. {{ total(num, orderDetails.goods.specs[0].selling_price) }}
  59. </view> -->
  60. </view>
  61. <button class="btn" @tap="submit">
  62. <text class="lf-font-32 text-white" v-if="type == 1">立即付款</text>
  63. <text class="lf-font-32 text-white" v-else>下单付款</text>
  64. </button>
  65. </view>
  66. </view>
  67. </skeleton>
  68. </block>
  69. </view>
  70. </template>
  71. <script>
  72. import bigc from '@/common/bigc.js';
  73. export default {
  74. data() {
  75. return {
  76. num: 1,
  77. skeletonLoading: true,
  78. checkbox: [{
  79. value: 'A',
  80. checked: true
  81. }],
  82. goods_id: 1,
  83. goods_specs_id: 1,
  84. orderDetails: {},
  85. ifchoose: true,
  86. ifCheck: true,
  87. type: 0,
  88. order_id: 0,
  89. ifDo: 1,
  90. ifPay: true,
  91. limit: 1,
  92. pt: 1
  93. }
  94. },
  95. computed: {
  96. total(){
  97. return function(num, price){
  98. let new_num = Number(num);
  99. if(Object.is(new_num, NaN)){
  100. return 0;
  101. };
  102. let big_price = new bigc(Number(price));
  103. big_price = big_price.times(new_num);
  104. return big_price.round(2, 0).toString();
  105. }
  106. },
  107. isRight(){
  108. return function(val){
  109. return this.$shared.isRight(val);
  110. }
  111. }
  112. },
  113. onLoad(e) {
  114. this.type = e.type;
  115. this.goods_id = e.goods_id;
  116. this.pt = e.pt || 1;
  117. this.order_id = e.order_id;
  118. this.goods_specs_id = e.goods_specs_id
  119. if(this.goods_id && this.goods_specs_id) {
  120. this.getConfirmOrder()
  121. }
  122. },
  123. methods: {
  124. changeNum(num) {
  125. if(num > this.limit) {
  126. this.$msg('该商品限购'+this.limit+'件')
  127. this.num = this.limit
  128. return
  129. }else if(num < 1) {
  130. this.num = 1
  131. }
  132. },
  133. getConfirmOrder() {
  134. this.$http(this.API.API_COFIRMORDER_DETAILS, {goods_id: this.goods_id,goods_specs_id: this.goods_specs_id}).then(res => {
  135. this.orderDetails = res.data
  136. this.limit = res.data.goods.specs[0].limit
  137. // this.limit = 10
  138. this.skeletonLoading = false
  139. })
  140. },
  141. reduce() {
  142. if (this.num === 1) return
  143. this.num--
  144. },
  145. add() {
  146. if(this.num < this.limit) {
  147. this.num++
  148. }else {
  149. this.$msg('该商品限购'+this.limit+'件')
  150. this.num = this.limit
  151. return
  152. }
  153. },
  154. CheckboxChange(e) {
  155. if(e.detail.value != '') {
  156. this.ifchoose = true
  157. }else {
  158. this.ifchoose = false
  159. }
  160. },
  161. // 点击复制
  162. copy(text) {
  163. uni.setClipboardData({
  164. data: text
  165. });
  166. },
  167. submit(){
  168. if(this.total(this.num,this.orderDetails.goods.specs[0].selling_price) == 0) {
  169. this.num = 1
  170. return this.$msg('商品数量格式不对!');
  171. }
  172. if(this.ifchoose == true) {
  173. if(!this.ifPay) return;
  174. this.ifPay = false;
  175. if(this.type == 1){
  176. this.pay();
  177. return;
  178. }
  179. this.$http(this.API.API_PRPAID, {
  180. goods_id: this.goods_id,
  181. goods_specs_id: this.goods_specs_id,
  182. number: this.num,
  183. payment_desc: this.pt
  184. }).then(res => {
  185. this.order_id = res.data.order_id
  186. uni.requestPayment({
  187. orderInfo: res.data.order_num,
  188. timeStamp: res.data.timeStamp,
  189. nonceStr: res.data.nonceStr,
  190. package: res.data.package,
  191. signType: res.data.signType,
  192. paySign: res.data.paySign,
  193. success: (res) => {
  194. this.ifPay = true
  195. this.$url('/pages/order/pay-success?ifSuccess=1&order_id='+this.order_id,{type: 'redirect'})
  196. },
  197. fail: (err) => {
  198. this.ifPay = true
  199. this.$url('/pages/order/pay-success?ifSuccess=2&order_id='+this.order_id,{type: 'redirect'})
  200. },
  201. })
  202. }).catch(err => {
  203. this.ifPay = true
  204. if(err.code == 9997) {
  205. uni.showModal({
  206. title: '提示',
  207. content: '是否同意前往手机授权?',
  208. success: e => {
  209. if (!e.confirm) return;
  210. this.$routerGo('/pages/login/index?type=phone')
  211. }
  212. });
  213. }
  214. });
  215. }else {
  216. this.$msg('请认真阅读并同意协议!')
  217. return
  218. }
  219. },
  220. pay(){
  221. this.$http(this.API.API_PAYMENT_DIRECT, {order_id: this.order_id}).then(res => {
  222. this.order_id = res.data.order_id
  223. uni.requestPayment({
  224. orderInfo: res.data.order_num,
  225. timeStamp: res.data.timeStamp,
  226. nonceStr: res.data.nonceStr,
  227. package: res.data.package,
  228. signType: res.data.signType,
  229. paySign: res.data.paySign,
  230. success: (res) => {
  231. this.$url('/pages/order/pay-success?ifSuccess=1&order_id='+this.order_id,{type: 'redirect'})
  232. },
  233. fail: (err) => {
  234. this.$url('/pages/order/pay-success?ifSuccess=2&order_id='+this.order_id,{type: 'redirect'})
  235. },
  236. })
  237. }).catch(err => {
  238. setTimeout(() => {
  239. this.$toBack()
  240. },1000)
  241. });
  242. },
  243. //下拉刷新
  244. downCallback() {
  245. this.getConfirmOrder()
  246. },
  247. },
  248. onShow() {
  249. if(this.ifDo > 1) {
  250. this.getConfirmOrder()
  251. }
  252. this.ifDo++
  253. }
  254. }
  255. </script>
  256. <style lang="scss" scoped>
  257. .btn{
  258. margin: 0;
  259. padding: 0;
  260. width: 208rpx;
  261. height: 80rpx;
  262. background-color: #FE9903;
  263. color: #FFFFFF;
  264. line-height: 80rpx;
  265. font-size: 32rpx;
  266. border-radius: 42rpx;
  267. }
  268. .bref-box {
  269. text-overflow: -o-ellipsis-lastline;
  270. overflow: hidden;
  271. text-overflow: ellipsis;
  272. display: -webkit-box;
  273. -webkit-line-clamp: 2;
  274. -webkit-box-orient: vertical;
  275. }
  276. </style>