confirmCompanyOrder.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658
  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="confirmUpdateMoney">
  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. salesVoucherCacheAddress(param).then(res=>{
  183. if(res.code ==200) {
  184. this.dataKey = res.dataKey
  185. if(this.isPrescribe) {
  186. uni.navigateTo({
  187. url: '/pages_company/order/editUserOrderPrescribe?orderKey='+this.orderKey+'&companyUserId='+this.companyUserId+"&dataKey="+this.dataKey+'&answerMedicine='+encodeURIComponent(JSON.stringify(this.answerMedicine)),
  188. })
  189. } else {
  190. uni.showToast({
  191. title: '提交成功,去分享吧',
  192. icon: 'none'
  193. })
  194. this.dataKey = res.dataKey
  195. this.disabled = false
  196. uni.showShareMenu()
  197. }
  198. } else {
  199. uni.showToast({
  200. title: res.msg,
  201. icon: 'none'
  202. })
  203. }
  204. })
  205. },
  206. checkPrescriptionDrug() {
  207. this.showBtn = false
  208. checkPrescriptionDrug({productIds:this.productIds}).then(res=>{
  209. if(res.code == 200) {
  210. this.showBtn = true
  211. this.isPrescribe = res.data
  212. this.answerMedicine = this.carts.map(it=>({
  213. medicineId:it.productId,
  214. number: it.num
  215. }))
  216. } else {
  217. uni.showToast({
  218. title: res.msg,
  219. icon: 'none'
  220. })
  221. }
  222. })
  223. },
  224. openUpdateMoney(){
  225. if(this.auditMoney) {
  226. uni.showModal({
  227. title: '提示',
  228. content: '✅ 实收金额改价申请审核中!',
  229. showCancel: false,
  230. success: function (res) {
  231. if (res.confirm) {
  232. console.log('用户点击确认');
  233. } else if (res.cancel) {
  234. console.log('用户点击取消');
  235. }
  236. }
  237. });
  238. return
  239. }
  240. this.inputShow = true
  241. },
  242. cancelUpdateMoney(){
  243. this.inputShow = false
  244. },
  245. confirmUpdateMoney(){
  246. if(parseFloat(this.inputTxt)>0){
  247. var that=this;
  248. var data={totalAmount: this.price.totalPrice,createOrderKey:this.orderKey,token:uni.getStorageSync('CompanyUserToken'),money:this.inputTxt}
  249. updateSalseOrderMoney(data).then(
  250. res => {
  251. if(res.code==200){
  252. this.auditMoney = res.disabled
  253. const canShare = !!(this.addressId && !res.disabled);
  254. this.disabled = !canShare;
  255. canShare ? uni.showShareMenu() : uni.hideShareMenu();
  256. this.inputShow = false
  257. this.getSalesOrder();
  258. uni.showModal({
  259. title: '提示',
  260. content: '✅ 实收金额改价申请已提交!',
  261. showCancel: false,
  262. success: function (res) {
  263. if (res.confirm) {
  264. uni.navigateBack()
  265. } else if (res.cancel) {
  266. console.log('用户点击取消');
  267. }
  268. }
  269. });
  270. }else{
  271. uni.showToast({
  272. icon:'none',
  273. title: res.msg,
  274. });
  275. }
  276. },
  277. rej => {}
  278. );
  279. }
  280. else{
  281. uni.showToast({
  282. icon:'none',
  283. title: "价格应大于0",
  284. });
  285. }
  286. },
  287. showDetail(item) {
  288. uni.navigateTo({
  289. url: 'productDetails?productId='+item.productId
  290. })
  291. },
  292. getSalesOrder(){
  293. var that=this;
  294. that.price.payPrice=0;
  295. that.price.totalPrice=0;
  296. var data={createOrderKey:this.orderKey}
  297. getSalesOrder(data).then(
  298. res => {
  299. if(res.code==200){
  300. this.carts=res.carts;
  301. this.carts.forEach(function(element) {
  302. that.price.payPrice+=element.price*element.cartNum;
  303. });
  304. that.price.totalPrice=res.totalMoney
  305. this.productIds = this.carts&&this.carts.length> 0?this.carts.map(item=>item.productId).join(','):'';
  306. this.checkPrescriptionDrug()
  307. }else{
  308. uni.showToast({
  309. icon:'none',
  310. title: res.msg,
  311. });
  312. }
  313. },
  314. rej => {}
  315. );
  316. },
  317. sharePrepare() {
  318. const param = {
  319. token:uni.getStorageSync('CompanyUserToken'),
  320. id:this.auditId,
  321. }
  322. sharePrepare(param).then(res=>{
  323. if(res.code==200) {
  324. if(this.addressId) {
  325. uni.showShareMenu()
  326. this.disabled = false
  327. }
  328. } else {
  329. uni.showToast({
  330. icon:'none',
  331. title: res.msg,
  332. });
  333. }
  334. })
  335. },
  336. getDetail() {
  337. let that = this
  338. changeListDetail(this.auditId).then(res=>{
  339. if(res.code==200){
  340. that.carts=res.data.preparedProductInfoVoList;
  341. that.price.payPrice = res.data.totalAmount
  342. that.price.totalPrice=res.data.money
  343. that.orderKey = res.data.createOrderKey
  344. that.productIds = that.carts&&that.carts.length> 0?that.carts.map(item=>item.productId).join(','):'';
  345. that.checkPrescriptionDrug()
  346. }else{
  347. uni.showToast({
  348. icon:'none',
  349. title: res.msg,
  350. });
  351. }
  352. })
  353. }
  354. }
  355. }
  356. </script>
  357. <style lang="scss">
  358. .inner-box{
  359. padding: 20upx 20upx 140upx;
  360. .address-box{
  361. box-sizing: border-box;
  362. min-height: 171upx;
  363. background: #FFFFFF;
  364. border-radius: 16upx;
  365. background-image: url(https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/app/newImages/shopping/address_bg.png);
  366. background-repeat: no-repeat;
  367. background-size: 100% 30upx;
  368. background-position: left bottom;
  369. padding: 38upx 30upx 36upx;
  370. display: flex;
  371. align-items: center;
  372. justify-content: space-between;
  373. .left{
  374. width: 92%;
  375. .name-box{
  376. display: flex;
  377. align-items: center;
  378. .text{
  379. font-size: 32upx;
  380. font-family: PingFang SC;
  381. font-weight: bold;
  382. color: #111111;
  383. line-height: 1;
  384. &.name{
  385. margin-right: 30upx;
  386. }
  387. }
  388. }
  389. .address{
  390. font-size: 28upx;
  391. font-family: PingFang SC;
  392. font-weight: 500;
  393. color: #666666;
  394. line-height: 42upx;
  395. text-align:left;
  396. margin-top: 23upx;
  397. }
  398. }
  399. .arrow-box{
  400. width: 12upx;
  401. height: 23upx;
  402. display: flex;
  403. align-items: cenetr;
  404. justify-content: cenetr;
  405. image{
  406. width: 100%;
  407. height: 100%;
  408. }
  409. }
  410. }
  411. .goods-list{
  412. margin-top: 20upx;
  413. padding: 0 30upx;
  414. background-color: #FFFFFF;
  415. border-radius: 16upx;
  416. .item{
  417. padding: 30upx 0;
  418. border-bottom: 1px solid #EDEEEF;
  419. display: flex;
  420. align-items: center;
  421. .img-box{
  422. width: 160upx;
  423. height: 160upx;
  424. margin-right: 30upx;
  425. image{
  426. width: 100%;
  427. height: 100%;
  428. }
  429. }
  430. .info-box{
  431. width: calc(100% - 190upx);
  432. height: 160upx;
  433. display: flex;
  434. flex-direction: column;
  435. justify-content: space-between;
  436. .name-box{
  437. font-size: 28upx;
  438. font-family: PingFang SC;
  439. font-weight: 500;
  440. color: #111111;
  441. line-height: 40upx;
  442. }
  443. .spec{
  444. margin-top: 10upx;
  445. font-size: 24upx;
  446. font-family: PingFang SC;
  447. font-weight: 500;
  448. color: #999999;
  449. line-height: 1;
  450. }
  451. .price-num{
  452. display: flex;
  453. align-items: center;
  454. justify-content: space-between;
  455. .price{
  456. display: flex;
  457. align-items: flex-end;
  458. .unit{
  459. font-size: 24upx;
  460. font-family: PingFang SC;
  461. font-weight: 500;
  462. color: #111111;
  463. line-height: 1.2;
  464. margin-right: 4upx;
  465. }
  466. .num{
  467. font-size: 32upx;
  468. font-family: PingFang SC;
  469. font-weight: 500;
  470. color: #111111;
  471. line-height: 1;
  472. }
  473. }
  474. .num{
  475. font-size: 24upx;
  476. font-family: PingFang SC;
  477. font-weight: 500;
  478. color: #999999;
  479. line-height: 1;
  480. }
  481. }
  482. }
  483. }
  484. .sub-total{
  485. height: 88upx;
  486. display: flex;
  487. align-items: center;
  488. justify-content: flex-end;
  489. .label{
  490. font-size: 24upx;
  491. font-family: PingFang SC;
  492. font-weight: 500;
  493. color: #999999;
  494. }
  495. .price{
  496. display: flex;
  497. align-items: flex-end;
  498. .unit{
  499. font-size: 24upx;
  500. font-family: PingFang SC;
  501. font-weight: 500;
  502. color: #FF6633;
  503. line-height: 1.2;
  504. margin-right: 4upx;
  505. }
  506. .num{
  507. font-size: 32upx;
  508. font-family: PingFang SC;
  509. font-weight: bold;
  510. color: #FF6633;
  511. line-height: 1;
  512. }
  513. }
  514. }
  515. }
  516. .points{
  517. height: 88upx;
  518. padding: 0 30upx;
  519. background: #FFFFFF;
  520. border-radius: 16upx;
  521. display: flex;
  522. align-items: center;
  523. justify-content: space-between;
  524. .left{
  525. display: flex;
  526. align-items: center;
  527. image{
  528. width: 28upx;
  529. height: 28upx;
  530. margin-right: 20upx;
  531. }
  532. .text{
  533. font-size: 28upx;
  534. font-family: PingFang SC;
  535. font-weight: 500;
  536. color: #666666;
  537. }
  538. }
  539. .right{
  540. display: flex;
  541. align-items: center;
  542. .text{
  543. font-size: 28upx;
  544. font-family: PingFang SC;
  545. font-weight: 500;
  546. color: #111111;
  547. }
  548. image{
  549. margin-left: 15upx;
  550. width: 14upx;
  551. height: 24upx;
  552. }
  553. }
  554. }
  555. .remarks{
  556. height: 88upx;
  557. padding: 0 30upx;
  558. background: #FFFFFF;
  559. border-radius: 16upx;
  560. margin-top: 20upx;
  561. display: flex;
  562. align-items: center;
  563. input{
  564. width: 100%;
  565. font-size: 28upx;
  566. font-family: PingFang SC;
  567. font-weight: 500;
  568. color: #000000;
  569. }
  570. .input{
  571. font-size: 28upx;
  572. font-family: PingFang SC;
  573. font-weight: 500;
  574. color: #999999;
  575. }
  576. }
  577. }
  578. .btn-foot{
  579. box-sizing: border-box;
  580. width: 100%;
  581. height: 121upx;
  582. background: #FFFFFF;
  583. padding: 16upx 30upx;
  584. display: flex;
  585. align-items: center;
  586. justify-content: flex-end;
  587. position: fixed;
  588. left: 0;
  589. bottom: 0;
  590. z-index: 99;
  591. .right{
  592. display: flex;
  593. align-items: center;
  594. .total{
  595. display: flex;
  596. align-items: flex-end;
  597. margin-right: 15upx;
  598. .label{
  599. font-size: 26upx;
  600. font-family: PingFang SC;
  601. font-weight: 500;
  602. color: #999999;
  603. line-height: 1.5;
  604. }
  605. .price{
  606. display: flex;
  607. align-items: flex-end;
  608. .unit{
  609. font-size: 28upx;
  610. font-family: PingFang SC;
  611. font-weight: bold;
  612. color: #FF6633;
  613. line-height: 1.2;
  614. margin-right: 10upx;
  615. }
  616. .num{
  617. font-size: 32upx;
  618. font-family: PingFang SC;
  619. font-weight: bold;
  620. color: #FF6633;
  621. line-height: 1;
  622. }
  623. }
  624. }
  625. .btn{
  626. margin-left: 10rpx;
  627. width: 180upx;
  628. height: 88upx;
  629. line-height: 88upx;
  630. text-align: center;
  631. font-size: 30upx;
  632. font-family: PingFang SC;
  633. font-weight: bold;
  634. color: #FFFFFF;
  635. background: #2583EB;
  636. border-radius: 44upx;
  637. position: relative;
  638. .share{
  639. display: inline-block;
  640. position: absolute;
  641. top: 0;
  642. left: 0;
  643. width: 100%;
  644. height: 100%rpx;
  645. opacity: 0;
  646. }
  647. }
  648. }
  649. }
  650. </style>