confirmCompanyOrder.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693
  1. <template>
  2. <view>
  3. <view class="inner-box">
  4. <!-- 收货人 -->
  5. <view class="address-box" v-if="address==null" @click="openAddress()">
  6. <view class="left">
  7. <view class="name-box">
  8. <text class="text name">添加收货地址</text>
  9. </view>
  10. </vie>
  11. </view>
  12. <view class="arrow-box">
  13. <image src="https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/app/newImages/shopping/arrow_gray.png" mode=""></image>
  14. </view>
  15. </view>
  16. <view class="address-box" v-if="address!=null" @click="openAddress()">
  17. <view class="left">
  18. <view class="name-box">
  19. <text class="text name">{{address.realName}}</text>
  20. <text class="text" v-if="address.phone!=null">{{address.phone}}</text>
  21. </view>
  22. <view class="address">
  23. {{address.province}}{{address.city}}{{address.district}}{{address.detail}}
  24. </view>
  25. </view>
  26. <view class="arrow-box">
  27. <image src="https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/app/newImages/shopping/arrow_gray.png" mode=""></image>
  28. </view>
  29. </view>
  30. <!-- 药品列表 -->
  31. <view class="goods-list">
  32. <view v-for="(item,index) in carts" :key="index" class="item" @click="showDetail(item)">
  33. <view class="img-box">
  34. <image :src="source=='audit'?item.image : item.productAttrImage||item.productImage" mode="aspectFill"></image>
  35. </view>
  36. <view class="info-box">
  37. <view>
  38. <view class="name-box ellipsis2">
  39. <view class="myotctxt" style="margin-right: 10rpx;" v-show="item.productType" :style="{background:_background(item.productType)}">{{$getDictLabelName("storeProductType",item.productType)}}</view>
  40. {{ item.commonName&&item.commonName!=='-'?item.commonName:item.productName }}
  41. </view>
  42. <view class="spec ellipsis2">{{item.productAttrName}}</view>
  43. </view>
  44. <view class="price-num">
  45. <view class="price">
  46. <text class="unit">¥</text>
  47. <text class="num">{{item.price?item.price.toFixed(2):'0.00'}}</text>
  48. </view>
  49. <view class="num">x{{item.cartNum}}</view>
  50. </view>
  51. </view>
  52. </view>
  53. <!-- 小计 -->
  54. <view class="sub-total">
  55. <text class="label">合计金额:</text>
  56. <view class="price">
  57. <text class="unit">¥</text>
  58. <text class="num">{{price.payPrice?price.payPrice.toFixed(2):'0.00'}}</text>
  59. </view>
  60. </view>
  61. </view>
  62. </view>
  63. <!-- 底部按钮 -->
  64. <view class="btn-foot">
  65. <view class="right">
  66. <view class="total" >
  67. <text class="label">总金额:</text>
  68. <view class="price">
  69. <text class="unit">¥</text>
  70. <text class="num">{{price.totalPrice?price.totalPrice.toFixed(2):'0.00'}}</text>
  71. </view>
  72. </view>
  73. <template v-if="showBtn">
  74. <view class="btn" @click="openUpdateMoney()" v-if="source!='audit'">
  75. 实收金额
  76. </view>
  77. <view class="btn" v-if="!disabled">
  78. 分享
  79. <button class="share" data-name="shareBtn" open-type="share">分享</button>
  80. </view>
  81. <view class="btn" v-else @click="handleShare()">提交订单</view>
  82. </template>
  83. </view>
  84. </view>
  85. <modal v-if="inputShow" title="实收金额" confirm-text="保存" cancel-text="取消" @cancel="cancelUpdateMoney" @confirm="confirm">
  86. <input type="text" v-model="inputTxt" placeholder="请输入实收金额" class="intxt" maxlength="8" />
  87. </modal>
  88. </view>
  89. </template>
  90. <script>
  91. import {getSalesOrder,getSalesOrders,updateSalseOrderMoney,sharePrepare,changeListDetail,salesVoucherCacheAddress,checkPrescriptionDrug} from '../api/companyOrder.js'
  92. export default {
  93. data() {
  94. return {
  95. inputShow:false,
  96. inputTxt:null,
  97. orderKey:null,
  98. price:{
  99. payPrice:0.00,
  100. totalPrice:0.00,
  101. },
  102. carts:[],
  103. disabled: true,
  104. source:'', // audit审核页过来的
  105. auditId:'',
  106. address:null,
  107. addressId: null,
  108. auditMoney: false,
  109. companyUserId: '',
  110. dataKey: '',
  111. productIds: '',
  112. showBtn: false,
  113. isPrescribe: false,
  114. answerMedicine: {},
  115. }
  116. },
  117. computed: {
  118. _background() {
  119. //productType: 1:OTC,2:Rx,3:非药品,4:器械
  120. return (productType)=> {
  121. switch (productType) {
  122. case 1: return '#37E2EA' // OTC
  123. case 2: return 'red' // Rx
  124. case 3: return '#2583EB' // 非药品
  125. case 4: return '#999' // 器械
  126. default: return '#ccc'
  127. }
  128. }
  129. }
  130. },
  131. onLoad(option) {
  132. this.source = option.source || ''
  133. uni.hideShareMenu()
  134. // this.disabled = true
  135. if(this.source == 'audit') {
  136. // uni.hideShareMenu()
  137. // this.disabled = true
  138. this.auditId = option.auditId || ''
  139. this.sharePrepare()
  140. this.getDetail()
  141. } else {
  142. this.orderKey=option.orderKey;
  143. // uni.showShareMenu()
  144. // uni.hideShareMenu()
  145. this.getSalesOrder();
  146. }
  147. uni.$on('updateAddress', (e) => {
  148. this.addressId=e.addressId;
  149. this.address=e;
  150. })
  151. this.companyUserId = uni.getStorageSync('companyUserId')
  152. },
  153. //发送给朋友
  154. onShareAppMessage(res) {
  155. return {
  156. title: "互易享",
  157. path: '/pages_company/order/confirmOrder?orderKey='+this.orderKey+'&companyUserId='+this.companyUserId+"&dataKey="+this.dataKey,
  158. imageUrl: 'https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/app/newImages/sharelogo.png' //分享图标,路径可以是本地文件路径、代码包文件路径或者网络图片路径.支持PNG及JPG。显示图片长宽比是 5:4
  159. }
  160. },
  161. onUnload() {
  162. uni.$off('updateAddress')
  163. },
  164. methods: {
  165. openAddress(){
  166. uni.navigateTo({
  167. url: '/pages_user/address'
  168. })
  169. },
  170. handleShare() {
  171. if(!this.addressId) {
  172. uni.showToast({
  173. title: '请选择地址',
  174. icon: 'none'
  175. })
  176. return
  177. }
  178. const param = {
  179. addressId:this.addressId,
  180. companyUserId:uni.getStorageSync('companyUserId')
  181. }
  182. this.saveCacheAddress(param)
  183. },
  184. saveCacheAddress(param,type) {
  185. uni.showLoading({
  186. title: '保存中'
  187. })
  188. salesVoucherCacheAddress(param).then(res=>{
  189. uni.hideLoading()
  190. if(res.code ==200) {
  191. this.dataKey = res.dataKey
  192. if(type==1) {
  193. this.confirmUpdateMoney()
  194. } else {
  195. if(this.isPrescribe) {
  196. uni.navigateTo({
  197. url: '/pages_company/order/editUserOrderPrescribe?orderKey='+this.orderKey+'&companyUserId='+this.companyUserId+"&dataKey="+this.dataKey+'&answerMedicine='+encodeURIComponent(JSON.stringify(this.answerMedicine)),
  198. })
  199. } else {
  200. uni.showToast({
  201. title: '提交成功,去分享吧',
  202. icon: 'none'
  203. })
  204. this.dataKey = res.dataKey
  205. this.disabled = false
  206. uni.showShareMenu()
  207. }
  208. }
  209. } else {
  210. uni.showToast({
  211. title: res.msg,
  212. icon: 'none'
  213. })
  214. }
  215. })
  216. },
  217. checkPrescriptionDrug() {
  218. this.showBtn = false
  219. checkPrescriptionDrug({productIds:this.productIds}).then(res=>{
  220. if(res.code == 200) {
  221. this.showBtn = true
  222. this.isPrescribe = res.data
  223. this.answerMedicine = this.carts.map(it=>({
  224. medicineId:it.productId,
  225. number: it.num
  226. }))
  227. } else {
  228. uni.showToast({
  229. title: res.msg,
  230. icon: 'none'
  231. })
  232. }
  233. })
  234. },
  235. openUpdateMoney(){
  236. if(this.auditMoney) {
  237. uni.showModal({
  238. title: '提示',
  239. content: '✅ 实收金额改价申请审核中!',
  240. showCancel: false,
  241. success: function (res) {
  242. if (res.confirm) {
  243. console.log('用户点击确认');
  244. } else if (res.cancel) {
  245. console.log('用户点击取消');
  246. }
  247. }
  248. });
  249. return
  250. }
  251. this.inputShow = true
  252. },
  253. cancelUpdateMoney(){
  254. this.inputShow = false
  255. },
  256. confirm() {
  257. // if(parseFloat(this.inputTxt)>0){
  258. // if(this.addressId) {
  259. // const param = {
  260. // addressId:this.addressId,
  261. // companyUserId:uni.getStorageSync('companyUserId')
  262. // }
  263. // this.saveCacheAddress(param,1)
  264. // } else {
  265. // this.confirmUpdateMoney()
  266. // }
  267. // } else {
  268. // uni.showToast({
  269. // icon:'none',
  270. // title: "价格应大于0",
  271. // });
  272. // }
  273. this.confirmUpdateMoney()
  274. },
  275. confirmUpdateMoney(){
  276. if(parseFloat(this.inputTxt)>0){
  277. var that=this;
  278. var data={totalAmount: this.price.totalPrice,createOrderKey:this.orderKey,token:uni.getStorageSync('CompanyUserToken'),money:this.inputTxt}
  279. uni.showLoading({
  280. title: '保存中'
  281. })
  282. updateSalseOrderMoney(data).then(
  283. res => {
  284. uni.hideLoading()
  285. if(res.code==200){
  286. this.auditMoney = res.disabled
  287. const canShare = !!(this.addressId && !res.disabled);
  288. this.disabled = !canShare;
  289. canShare ? uni.showShareMenu() : uni.hideShareMenu();
  290. this.inputShow = false
  291. this.getSalesOrder();
  292. uni.showModal({
  293. title: '提示',
  294. content: '✅ 实收金额改价申请已提交!',
  295. showCancel: false,
  296. success: function (res) {
  297. if (res.confirm) {
  298. uni.navigateBack()
  299. } else if (res.cancel) {
  300. console.log('用户点击取消');
  301. }
  302. }
  303. });
  304. }else{
  305. uni.showToast({
  306. icon:'none',
  307. title: res.msg,
  308. });
  309. }
  310. },
  311. rej => {}
  312. );
  313. }
  314. else{
  315. uni.showToast({
  316. icon:'none',
  317. title: "价格应大于0",
  318. });
  319. }
  320. },
  321. showDetail(item) {
  322. uni.navigateTo({
  323. url: 'productDetails?productId='+item.productId
  324. })
  325. },
  326. getSalesOrder(){
  327. var that=this;
  328. that.price.payPrice=0;
  329. that.price.totalPrice=0;
  330. var data={createOrderKey:this.orderKey}
  331. getSalesOrder(data).then(
  332. res => {
  333. if(res.code==200){
  334. this.carts=res.carts;
  335. this.carts.forEach(function(element) {
  336. that.price.payPrice+=element.price*element.cartNum;
  337. });
  338. that.price.totalPrice=res.totalMoney
  339. this.productIds = this.carts&&this.carts.length> 0?this.carts.map(item=>item.productId).join(','):'';
  340. this.checkPrescriptionDrug()
  341. }else{
  342. uni.showToast({
  343. icon:'none',
  344. title: res.msg,
  345. });
  346. }
  347. },
  348. rej => {}
  349. );
  350. },
  351. sharePrepare() {
  352. const param = {
  353. token:uni.getStorageSync('CompanyUserToken'),
  354. id:this.auditId,
  355. }
  356. sharePrepare(param).then(res=>{
  357. if(res.code==200) {
  358. if(this.addressId) {
  359. uni.showShareMenu()
  360. this.disabled = false
  361. }
  362. } else {
  363. uni.showToast({
  364. icon:'none',
  365. title: res.msg,
  366. });
  367. }
  368. })
  369. },
  370. getDetail() {
  371. let that = this
  372. changeListDetail(this.auditId).then(res=>{
  373. if(res.code==200){
  374. that.carts=res.data.preparedProductInfoVoList;
  375. that.price.payPrice = res.data.totalAmount
  376. that.price.totalPrice=res.data.money
  377. that.orderKey = res.data.createOrderKey
  378. that.productIds = that.carts&&that.carts.length> 0?that.carts.map(item=>item.productId).join(','):'';
  379. that.checkPrescriptionDrug()
  380. }else{
  381. uni.showToast({
  382. icon:'none',
  383. title: res.msg,
  384. });
  385. }
  386. })
  387. }
  388. }
  389. }
  390. </script>
  391. <style lang="scss">
  392. .inner-box{
  393. padding: 20upx 20upx 140upx;
  394. .address-box{
  395. box-sizing: border-box;
  396. min-height: 171upx;
  397. background: #FFFFFF;
  398. border-radius: 16upx;
  399. background-image: url(https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/app/newImages/shopping/address_bg.png);
  400. background-repeat: no-repeat;
  401. background-size: 100% 30upx;
  402. background-position: left bottom;
  403. padding: 38upx 30upx 36upx;
  404. display: flex;
  405. align-items: center;
  406. justify-content: space-between;
  407. .left{
  408. width: 92%;
  409. .name-box{
  410. display: flex;
  411. align-items: center;
  412. .text{
  413. font-size: 32upx;
  414. font-family: PingFang SC;
  415. font-weight: bold;
  416. color: #111111;
  417. line-height: 1;
  418. &.name{
  419. margin-right: 30upx;
  420. }
  421. }
  422. }
  423. .address{
  424. font-size: 28upx;
  425. font-family: PingFang SC;
  426. font-weight: 500;
  427. color: #666666;
  428. line-height: 42upx;
  429. text-align:left;
  430. margin-top: 23upx;
  431. }
  432. }
  433. .arrow-box{
  434. width: 12upx;
  435. height: 23upx;
  436. display: flex;
  437. align-items: cenetr;
  438. justify-content: cenetr;
  439. image{
  440. width: 100%;
  441. height: 100%;
  442. }
  443. }
  444. }
  445. .goods-list{
  446. margin-top: 20upx;
  447. padding: 0 30upx;
  448. background-color: #FFFFFF;
  449. border-radius: 16upx;
  450. .item{
  451. padding: 30upx 0;
  452. border-bottom: 1px solid #EDEEEF;
  453. display: flex;
  454. align-items: center;
  455. .img-box{
  456. width: 160upx;
  457. height: 160upx;
  458. margin-right: 30upx;
  459. image{
  460. width: 100%;
  461. height: 100%;
  462. }
  463. }
  464. .info-box{
  465. width: calc(100% - 190upx);
  466. height: 160upx;
  467. display: flex;
  468. flex-direction: column;
  469. justify-content: space-between;
  470. .name-box{
  471. font-size: 28upx;
  472. font-family: PingFang SC;
  473. font-weight: 500;
  474. color: #111111;
  475. line-height: 40upx;
  476. }
  477. .spec{
  478. margin-top: 10upx;
  479. font-size: 24upx;
  480. font-family: PingFang SC;
  481. font-weight: 500;
  482. color: #999999;
  483. line-height: 1;
  484. }
  485. .price-num{
  486. display: flex;
  487. align-items: center;
  488. justify-content: space-between;
  489. .price{
  490. display: flex;
  491. align-items: flex-end;
  492. .unit{
  493. font-size: 24upx;
  494. font-family: PingFang SC;
  495. font-weight: 500;
  496. color: #111111;
  497. line-height: 1.2;
  498. margin-right: 4upx;
  499. }
  500. .num{
  501. font-size: 32upx;
  502. font-family: PingFang SC;
  503. font-weight: 500;
  504. color: #111111;
  505. line-height: 1;
  506. }
  507. }
  508. .num{
  509. font-size: 24upx;
  510. font-family: PingFang SC;
  511. font-weight: 500;
  512. color: #999999;
  513. line-height: 1;
  514. }
  515. }
  516. }
  517. }
  518. .sub-total{
  519. height: 88upx;
  520. display: flex;
  521. align-items: center;
  522. justify-content: flex-end;
  523. .label{
  524. font-size: 24upx;
  525. font-family: PingFang SC;
  526. font-weight: 500;
  527. color: #999999;
  528. }
  529. .price{
  530. display: flex;
  531. align-items: flex-end;
  532. .unit{
  533. font-size: 24upx;
  534. font-family: PingFang SC;
  535. font-weight: 500;
  536. color: #FF6633;
  537. line-height: 1.2;
  538. margin-right: 4upx;
  539. }
  540. .num{
  541. font-size: 32upx;
  542. font-family: PingFang SC;
  543. font-weight: bold;
  544. color: #FF6633;
  545. line-height: 1;
  546. }
  547. }
  548. }
  549. }
  550. .points{
  551. height: 88upx;
  552. padding: 0 30upx;
  553. background: #FFFFFF;
  554. border-radius: 16upx;
  555. display: flex;
  556. align-items: center;
  557. justify-content: space-between;
  558. .left{
  559. display: flex;
  560. align-items: center;
  561. image{
  562. width: 28upx;
  563. height: 28upx;
  564. margin-right: 20upx;
  565. }
  566. .text{
  567. font-size: 28upx;
  568. font-family: PingFang SC;
  569. font-weight: 500;
  570. color: #666666;
  571. }
  572. }
  573. .right{
  574. display: flex;
  575. align-items: center;
  576. .text{
  577. font-size: 28upx;
  578. font-family: PingFang SC;
  579. font-weight: 500;
  580. color: #111111;
  581. }
  582. image{
  583. margin-left: 15upx;
  584. width: 14upx;
  585. height: 24upx;
  586. }
  587. }
  588. }
  589. .remarks{
  590. height: 88upx;
  591. padding: 0 30upx;
  592. background: #FFFFFF;
  593. border-radius: 16upx;
  594. margin-top: 20upx;
  595. display: flex;
  596. align-items: center;
  597. input{
  598. width: 100%;
  599. font-size: 28upx;
  600. font-family: PingFang SC;
  601. font-weight: 500;
  602. color: #000000;
  603. }
  604. .input{
  605. font-size: 28upx;
  606. font-family: PingFang SC;
  607. font-weight: 500;
  608. color: #999999;
  609. }
  610. }
  611. }
  612. .btn-foot{
  613. box-sizing: border-box;
  614. width: 100%;
  615. height: 121upx;
  616. background: #FFFFFF;
  617. padding: 16upx 30upx;
  618. display: flex;
  619. align-items: center;
  620. justify-content: flex-end;
  621. position: fixed;
  622. left: 0;
  623. bottom: 0;
  624. z-index: 99;
  625. .right{
  626. display: flex;
  627. align-items: center;
  628. .total{
  629. display: flex;
  630. align-items: flex-end;
  631. margin-right: 15upx;
  632. .label{
  633. font-size: 26upx;
  634. font-family: PingFang SC;
  635. font-weight: 500;
  636. color: #999999;
  637. line-height: 1.5;
  638. }
  639. .price{
  640. display: flex;
  641. align-items: flex-end;
  642. .unit{
  643. font-size: 28upx;
  644. font-family: PingFang SC;
  645. font-weight: bold;
  646. color: #FF6633;
  647. line-height: 1.2;
  648. margin-right: 10upx;
  649. }
  650. .num{
  651. font-size: 32upx;
  652. font-family: PingFang SC;
  653. font-weight: bold;
  654. color: #FF6633;
  655. line-height: 1;
  656. }
  657. }
  658. }
  659. .btn{
  660. margin-left: 10rpx;
  661. width: 180upx;
  662. height: 88upx;
  663. line-height: 88upx;
  664. text-align: center;
  665. font-size: 30upx;
  666. font-family: PingFang SC;
  667. font-weight: bold;
  668. color: #FFFFFF;
  669. background: #2583EB;
  670. border-radius: 44upx;
  671. position: relative;
  672. .share{
  673. display: inline-block;
  674. position: absolute;
  675. top: 0;
  676. left: 0;
  677. width: 100%;
  678. height: 100%rpx;
  679. opacity: 0;
  680. }
  681. }
  682. }
  683. }
  684. </style>