affirm.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  1. <template>
  2. <view class="affirm-page">
  3. <view class="affirm-view overscroll">
  4. <form>
  5. <view class="module-com">
  6. <view class="commodity-view">
  7. <view class="commodity-list">
  8. <view class="commodity-item" v-for="(item, index) in selectList" :key="index" >
  9. <image class="item-icon" :src="item.cover" />
  10. <view class="item-info">
  11. <view class="info-line">
  12. <text class="item-name">{{ item.itemName }}</text>
  13. <text class="item-price">
  14. <text class="price">
  15. ¥{{ item.userPrice ? parseFloat(item.userPrice) : 0 }}
  16. </text>
  17. </text>
  18. </view>
  19. <view class="info-line">
  20. <text class="item-type" v-if="item.ratioType == 0">{{item.ratio}}{{item.smallUnit}}/{{item.bigUnit}}</text>
  21. <text class="item-type" v-else>若干{{item.smallUnit}}/{{item.bigUnit}}</text>
  22. <text class="item-count">
  23. x <text v-if="Number(item.bigCount) > 0">{{ item.bigCount }}{{item.bigUnit}}</text>
  24. <text v-if="Number(item.smallCount) > 0">{{ item.smallCount }}{{item.smallUnit}}</text>
  25. </text>
  26. </view>
  27. </view>
  28. </view>
  29. </view>
  30. <view class="summary-bar">
  31. <view class="operate-view" @click="gobackEvent">
  32. <text class="iconfont icongouwuche"></text>返回修改
  33. </view>
  34. <view class="describe-view">
  35. 共<text v-if="Number(allCount.bigLength)>0">{{ allCount.bigLength }}扎</text>
  36. <text v-if="Number(allCount.smallLength)>0">{{ allCount.smallLength }}支</text>,
  37. 合计 <text class="price">¥{{ allPrice }}</text>
  38. </view>
  39. </view>
  40. </view>
  41. </view>
  42. <view class="module-com input-line-wrap">
  43. <tui-list-cell class="line-cell" :hover="false" :arrow="false">
  44. <view class="tui-title ">客户</view>
  45. <view class="tui-input" v-if="clientInfo.id">{{ clientInfo.name }}</view>
  46. <view class="tui-placeholder" style="width: 100%" v-else>游客</view>
  47. </tui-list-cell>
  48. <tui-list-cell class="line-cell" :hover="false" :arrow="false">
  49. <view class="tui-title">结账方式</view>
  50. <button @tap="hasPay = 1" class="admin-button-com middle" :class="hasPay == 1 ? 'blue' : 'default'">线下</button>
  51. <button @click="hasPay = 2" class="admin-button-com middle" :class="hasPay == 2 ? 'blue' : 'default'">赊账</button>
  52. </tui-list-cell>
  53. <tui-list-cell class="line-cell" :arrow="true" v-if="hasPay == 1">
  54. <div class="tui-title">线下方式</div>
  55. <picker mode="selector" :value="payWay" :range="payWayList" range-key="name" @change="payWayChange" class="tui-input" >
  56. <input v-model="payWay" name="payWay" type="text" hidden />
  57. <div style="padding:6upx 0 6upx 0;">{{payWayList[payWayindex].name}}</div>
  58. </picker>
  59. </tui-list-cell>
  60. <tui-list-cell class="line-cell" :hover="false" :arrow="false" >
  61. <view class="tui-title ">包装费</view>
  62. <input type="number" placeholder="包装费" @input="countAllPrices()" v-model="packingMoney" placeholder-class="tui-placeholder">
  63. </tui-list-cell>
  64. <tui-list-cell class="line-cell" :hover="false" :arrow="false" >
  65. <view class="tui-title ">运费</view>
  66. <input type="number" placeholder="选填" v-model="freight" @input="countAllPrices()" placeholder-class="tui-placeholder">
  67. </tui-list-cell>
  68. <tui-list-cell class="line-cell" :hover="false" :arrow="false" >
  69. <view class="tui-title">总金额</view>
  70. <text style="color: #3385FF" >{{ (allPrice+Number(packingMoney)+Number(freight)).toFixed(2) }}</text>
  71. </tui-list-cell>
  72. <tui-list-cell class="line-cell" :hover="false" :arrow="false" >
  73. <view class="tui-title">实收金额</view>
  74. <view class="flex-space" style="width: 100%;">
  75. <input style="border: 1px solid #eee;color: #3385FF;width: 60%;height:70upx;" type="number" @focus="modifyPrice='',discountIndex=0" v-model="modifyPrice" placeholder-class="tui-placeholder"/>
  76. <picker style="border: 1px solid #eee;width: 30%;" @change="discountChange" :value="discountIndex" :range="discount">
  77. <view class="flex-space" style="height:70upx;">
  78. <view class="uni-input">{{discount[discountIndex]}}</view>
  79. <i class="iconfont iconxiangyou"></i>
  80. </view>
  81. </picker>
  82. </view>
  83. <!--<input style="border: 1px solid #eee;color: #3385FF;width: calc(100%);" type="number" @focus="modifyPrice=''" v-model="modifyPrice" placeholder-class="tui-placeholder"/>-->
  84. </tui-list-cell>
  85. <tui-list-cell class="line-cell" :hover="false" :arrow="false" >
  86. <view class="tui-title">优惠</view>
  87. <text style="color: #3385FF">{{ ((allPrice+Number(packingMoney)+Number(freight)).toFixed(2) - modifyPrice).toFixed(2) }}</text>
  88. </tui-list-cell>
  89. </view>
  90. </form>
  91. </view>
  92. <view class="under-bar">
  93. <view class="price-view">
  94. <text class="price-title">收款</text>
  95. <text class="price-number">
  96. ¥ <text class="large">{{ modifyPrice }}</text>
  97. </text>
  98. </view>
  99. <button class="admin-button-com blue big" @click="affirmFormSubmit">开单</button>
  100. </view>
  101. <!-- 选择客户 -->
  102. <AppCustomerSel :show.sync="showCustomer" @change="changeCustomerFn" />
  103. </view>
  104. </template>
  105. <script>
  106. import TuiListCell from "@/components/plugin/list-cell";
  107. import AppAvatarModule from "@/components/module/app-avatar";
  108. import SimpleAddress from "@/components/plugin/simple-address";
  109. import AppAreaSel from "@/components/app-area-sel";
  110. import AppCustomerSel from "@/components/app-customer-sel";
  111. import productMins from "@/mixins/product";
  112. import appFormRadioBtn from "@/components/app-formRadio-btn";
  113. import appAddressGroup from "@/components/app-address-group";
  114. import appSendTime from "@/components/app-send-time";
  115. const formUtil = require("@/utils/formValidation.js");
  116. import { createOrder } from "@/api/order/index";
  117. import { mapActions, mapGetters } from "vuex";
  118. export default {
  119. name: "affirm",
  120. components: {
  121. TuiListCell,
  122. AppAvatarModule,
  123. SimpleAddress,
  124. AppAreaSel,
  125. AppCustomerSel,
  126. appFormRadioBtn,
  127. appAddressGroup,
  128. appSendTime
  129. },
  130. mixins: [productMins],
  131. data() {
  132. return {
  133. autoLoad: false,
  134. packingMoney:'',//包装费
  135. freight:'',//运费
  136. modifyPrice:0,//真实金额
  137. payWay:0,//支付类型
  138. clientInfo: '',//客户信息
  139. showCustomer: false,
  140. sendType:1,
  141. discountIndex:0,
  142. discount:['打折','95折','9折','85折','8折','75折','7折','65折','6折'],
  143. payWayList:[{name:"线下微信",id:0},{name:"线下支付宝",id:1},{name:"现金",id:4},{name:"银行卡",id:5}],
  144. payWayindex:0,
  145. hasPay:1
  146. };
  147. },
  148. onLoad() {
  149. if (!this.getMerchantInfo) {
  150. this.initMerchantInfo().then(data => {
  151. uni.setNavigationBarTitle({
  152. title: data.name
  153. });
  154. });
  155. } else {
  156. uni.setNavigationBarTitle({
  157. title: this.getMerchantInfo.name
  158. });
  159. }
  160. this.modifyPrice = this.allPrice.toFixed(2);
  161. },
  162. computed: {
  163. ...mapGetters(["getMerchantInfo", "getLoginInfo","getDictionariesInfo"])
  164. },
  165. methods: {
  166. ...mapActions(["initMerchantInfo"]),
  167. payWayChange(e){
  168. let index = e.detail.value
  169. this.payWayindex = index
  170. this.payWay = this.payWayList[index].id
  171. },
  172. discountChange(e){
  173. this.discountIndex = e.target.value;
  174. let discount = 0;
  175. let Prices = this.allPrice.toFixed(2)
  176. let allPrices = (Number(Prices) + Number(this.freight) + Number(this.packingMoney)).toFixed(2);
  177. switch (e.target.value) {
  178. case '0':
  179. discount = 0
  180. break;
  181. case '1':
  182. discount = (allPrices - (allPrices * 0.95)).toFixed(2);
  183. break;
  184. case '2':
  185. discount = (allPrices - (allPrices * 0.9)).toFixed(2);
  186. break;
  187. case '3':
  188. discount = (allPrices - (allPrices * 0.85)).toFixed(2);
  189. break;
  190. case '4':
  191. discount = (allPrices - (allPrices * 0.8)).toFixed(2);
  192. break;
  193. case '5':
  194. discount = (allPrices - (allPrices * 0.75)).toFixed(2);
  195. break;
  196. case '6':
  197. discount = (allPrices - (allPrices * 0.7)).toFixed(2);
  198. break;
  199. case '7':
  200. discount = (allPrices - (allPrices * 0.65)).toFixed(2);
  201. break;
  202. case '8':
  203. discount = (allPrices - (allPrices * 0.6)).toFixed(2);
  204. break;
  205. }
  206. this.modifyPrice = (allPrices - discount).toFixed(2);
  207. },
  208. countAllPrices(){
  209. let allPrices = this.allPrice.toFixed(2)
  210. this.modifyPrice = (Number(allPrices) + Number(this.freight) + Number(this.packingMoney)).toFixed(2);
  211. },
  212. changeCustomerFn(info) {
  213. this.clientInfo = info;
  214. },
  215. affirmFormSubmit(){
  216. if(this.$util.isEmpty(this.selectList)){
  217. this.$msg('请选择花材')
  218. return false
  219. }
  220. let product = []
  221. this.selectList.forEach((item,idx,arr) => {
  222. let unitType = Number(item.bigCount)>0 ? 0 : 1
  223. let num = Number(item.bigCount)>0 ? Number(item.bigCount) : Number(item.smallCount)
  224. let unitPrice = item.userPrice ? item.userPrice : 0
  225. let current = {productId:item.id,bigNum:item.bigCount,smallNum:item.smallCount,classId:item.classId,num:num,
  226. itemId:item.itemId,property:item.property,unitType:unitType,unitPrice:unitPrice}
  227. product.push(current)
  228. })
  229. let packingFee = Number(this.packingMoney) > 0 ? Number(this.packingMoney) : 0
  230. let options = {
  231. orderType:2,//开单类型,1商品开单 2花材开单
  232. packingFee:packingFee,
  233. sendCost:this.freight,
  234. customId:this.clientInfo.id,
  235. payWay:this.payWay,
  236. sendType:this.sendType,
  237. modifyPrice: this.modifyPrice,
  238. product:JSON.stringify(product),
  239. hasPay:this.hasPay
  240. };
  241. let that = this;
  242. that.$util.confirmModal({content:'确认开单?'},() => {
  243. uni.showLoading({mask:true})
  244. createOrder(options).then(res => {
  245. uni.hideLoading()
  246. that.removeFromSaveDirect()
  247. const { data: { id } } = res
  248. let url = `/admin/billing/result?orderId=${id}`;
  249. uni.redirectTo({url: url})
  250. })
  251. })
  252. },
  253. gobackEvent() {
  254. if(this.option.customId){
  255. this.$util.pageTo({url: '/admin/billing/index',type:2,query: {customId: this.option.customId}})
  256. }else{
  257. this.$util.pageTo({url: '/admin/billing/index',type:2})
  258. }
  259. }
  260. }
  261. };
  262. </script>
  263. <style lang="scss" scoped>
  264. .admin-button-com {
  265. margin-right: 20upx;
  266. }
  267. .affirm-page {
  268. position: relative;
  269. height: 100%;
  270. display: flex;
  271. flex-direction: column;
  272. .affirm-view {
  273. flex: 1;
  274. padding: 20upx;
  275. background-color: #f0f2f6;
  276. .commodity-view {
  277. display: flex;
  278. flex-direction: column;
  279. .commodity-list {
  280. padding: 20upx;
  281. .commodity-item {
  282. display: flex;
  283. margin-bottom: 20upx;
  284. .item-icon {
  285. flex-shrink: 0;
  286. width: 140upx;
  287. height: 140upx;
  288. }
  289. .item-info {
  290. display: flex;
  291. flex-direction: column;
  292. justify-content: center;
  293. flex: 1;
  294. margin-left: 20upx;
  295. .info-line {
  296. margin-bottom: 20upx;
  297. display: flex;
  298. justify-content: space-between;
  299. align-items: flex-end;
  300. .item-name {
  301. color: #333333;
  302. font-size:30upx;
  303. font-weight:bold;
  304. }
  305. .item-price {
  306. color: #333;
  307. font-size: 22upx;
  308. .price {
  309. font-size: 32upx;
  310. font-weight: bold;
  311. }
  312. }
  313. .item-type {
  314. color: #999;
  315. font-size: 24upx;
  316. }
  317. .item-count {
  318. color: #666;
  319. font-size: 24upx;
  320. }
  321. }
  322. }
  323. }
  324. }
  325. .summary-bar {
  326. padding: 0 20upx;
  327. height: 90upx;
  328. display: flex;
  329. align-items: center;
  330. justify-content: space-between;
  331. border-top: 1px solid #eeeeee;
  332. .operate-view {
  333. display: flex;
  334. align-items: center;
  335. color: #3385ff;
  336. font-size: 30upx;
  337. font-weight:bold;
  338. .iconfont {
  339. margin-right: 20upx;
  340. font-size: 40upx;
  341. }
  342. }
  343. .describe-view {
  344. display: flex;
  345. align-items: center;
  346. color: #333;
  347. font-size: 24upx;
  348. .price {
  349. font-weight: bold;
  350. font-size: 34upx;
  351. margin-left:8upx;
  352. }
  353. }
  354. }
  355. }
  356. .module-com {
  357. background-color: #fff;
  358. margin-bottom: 20upx;
  359. border-radius: 10upx;
  360. overflow: hidden;
  361. .member-wrap {
  362. .member-det {
  363. font-size: 24upx;
  364. margin-left: 20upx;
  365. }
  366. }
  367. .remark-wrap {
  368. align-items: flex-start;
  369. .remark {
  370. height: 240upx;
  371. }
  372. }
  373. }
  374. }
  375. .under-bar {
  376. display: flex;
  377. justify-content: space-between;
  378. align-items: center;
  379. padding: 0 20upx;
  380. width: 100%;
  381. height: 100upx;
  382. background-color: #fff;
  383. box-shadow: 0upx -1px 6upx 0upx rgba(4, 0, 0, 0.06);
  384. .price-view {
  385. display: flex;
  386. align-items: center;
  387. font-size: 24upx;
  388. .price-title {
  389. color: #333;
  390. }
  391. .price-number {
  392. margin: 0 20upx;
  393. color: #ff2842;
  394. .large {
  395. font-size: 40upx;
  396. }
  397. }
  398. }
  399. .admin-button-com {
  400. width: 200upx;
  401. }
  402. }
  403. }
  404. </style>