耀实惠小程序
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.

445 lines
13 KiB

  1. <template>
  2. <view class="confirm-subscribe flex-1">
  3. <view class="confirm-subscribe-item">
  4. <select-drug-user v-if="address" :DrugInfo='address' :type="2" ></select-drug-user>
  5. </view>
  6. <view class="confirm-subscribe-item">
  7. <view class="flex align-start font-30 font-weight-bold ">
  8. <text class="text-red">*</text> <text class="text-black font-30">线下已确诊疾病</text>
  9. </view>
  10. <view class="font-24 text-grey">
  11. *请根据线下就诊情况确认或选择确诊疾病
  12. </view>
  13. <view class="flex align-center flex-wrap m-b-30">
  14. <view
  15. v-for="(item, index) in diseaseList"
  16. @click="selectDisease(item, index)"
  17. :key="index"
  18. :class="{'confirm-subscribe-item-tag--active': new Set(selectList).has(item)}"
  19. class="confirm-subscribe-item-tag flex align-center justify-center font-24 m-r-16 m-t-26"
  20. >
  21. {{ item }}
  22. </view>
  23. <view class="confirm-subscribe-item-tag flex align-center justify-center font-24 m-t-26" @click="show = true">
  24. +添加疾病
  25. </view>
  26. </view>
  27. <view class="flex justify-between align-center m-t-20 m-b-30 font-30 font-weight-bold">
  28. <text>确认服用过该药且无禁忌症及不良反应</text>
  29. <u-switch v-model="checked"></u-switch>
  30. </view>
  31. <view class="flex flex-column justify-start ">
  32. <text class=" font-30 font-weight-bold m-t-20 m-b-20">处方/病历/检查报告选填</text>
  33. <text class=" font-28 m-b-10" style="color: #AFAFAF;">您上传的病例资料将为医生开具处方提供参考</text>
  34. <view class="hint_pic">
  35. <u-upload ref="uUpload3"
  36. :header="headerInfo"
  37. :action="upload_img"
  38. :custom-btn="true"
  39. image-mode="none"
  40. @on-remove="closeImg"
  41. @on-success="onSuccess"
  42. @on-error="onErrorInfo"
  43. max-count="1" width="281" height="192" >
  44. <view slot="addBtn" class="slot-btn" hover-class="slot-btn__hover" hover-stay-time="150">
  45. <image :src="form.hintImage?form.hintImage:(IMG_URL+'upLoad.png')" mode=""></image>
  46. </view>
  47. </u-upload>
  48. </view>
  49. </view>
  50. </view>
  51. <view class="confirm-subscribe-footer position-fixed flex align-center justify-center">
  52. <u-button type="primary" shape="circle" @click="confirm">预约</u-button>
  53. </view>
  54. <u-popup v-model="show" mode="bottom" height="50vh">
  55. <view class="p-20">
  56. <u-search placeholder="请输入要添加的疾病" v-model="keyword" height="80" @search="offlinediagnosisList(1)" @custom="offlinediagnosisList(1)"></u-search>
  57. </view>
  58. <scroll-view scroll-y class="confirm-subscribe-scroll" @scrolltolower="illnessList()">
  59. <view class="text-center p-t-20 font-28 text-black" v-if="showList.length == 0">
  60. 未搜索到该疾病
  61. </view>
  62. <view class="p-l-20 p-r-20">
  63. <view class="confirm-subscribe-scroll-item p-t-20 p-b-20" v-for="item in showList" :key="item.id" @click="handleDisease(item)">
  64. {{item.name}}
  65. </view>
  66. </view>
  67. </scroll-view>
  68. </u-popup>
  69. </view>
  70. </template>
  71. <script>
  72. import { IMG_URL } from '@/env.js';
  73. export default {
  74. data() {
  75. return {
  76. IMG_URL,
  77. show: false,
  78. diseaseList: [],
  79. selectList: [],
  80. current: '',
  81. keyword: '',
  82. goodsId: '', //商品id
  83. address: null ,// 用药人
  84. drugUserInfo: null,
  85. type: '',
  86. pageNo:1,
  87. pageSize:10,
  88. total: null,
  89. isLock: true ,//锁
  90. isSituation: null,
  91. num: '',
  92. price: '',
  93. goodSkuParam: '',
  94. prescriptionId: null,
  95. addressId: null,
  96. orderType: null,
  97. preventionId: null, //防疫id
  98. // 添加疾病
  99. showList: [],
  100. checked: false,
  101. // 图片
  102. upload_img: '',
  103. href: 'api/info/upload',
  104. headerInfo: {
  105. "content-type": "application/x-www-form-urlencoded",
  106. "X-Access-Token": ''
  107. },
  108. imgUpload: '' , // 上传的图片地址
  109. imgUploadShow: '', // 拍方抓药
  110. createOrderType: '',
  111. payType: '',
  112. isZone: '',
  113. patterId:''
  114. }
  115. },
  116. onLoad(options) {
  117. this.upload_img = this.$upload_img;
  118. console.log(4444444,options)
  119. this.payType = options.payType;
  120. this.createOrderType = options.createOrderType;
  121. this.goodsId = options.goodsId;
  122. this.addressId = options.addressId;
  123. this.type = options.type;
  124. this.isSituation = options.isSituation
  125. this.num = options.num;
  126. this.price = options.price;
  127. this.imgUploadShow = options.imgUploadShow;
  128. this.goodSkuParam = options.goodSkuParam;
  129. this.prescriptionId = options.prescriptionId;
  130. this.preventionId = options.preventionId;
  131. this.orderType = options.orderType;
  132. this.isZone = options.isZone;
  133. this.patterId = options.patterId == null?'':options.patterId;
  134. if(options.medicineMan) {
  135. this.address = JSON.parse(options.medicineMan);
  136. }
  137. console.log(5555,this.patterId)
  138. this.offlinediagnosisList();
  139. // 获取上传图片需要的信息
  140. let token = uni.getStorageSync("__user_token");
  141. this.headerInfo["X-Access-Token"] = token;
  142. this.getGoodsdetail(this.goodsId);
  143. },
  144. methods: {
  145. // 商品详情
  146. getGoodsdetail(id){
  147. uni.showLoading();
  148. this.$api('getGoodsdetail',{id})
  149. .then(res => {
  150. let { code, result, message } = res;
  151. uni.hideLoading();
  152. if(code == 200) {
  153. const list = result.disease?result.disease.split(","): []
  154. console.log(list)
  155. list.forEach(item => {
  156. this.diseaseList.push(item)
  157. })
  158. }else {
  159. let tips = message.indexOf('操作失败') > -1 ? '商品不存在' : message
  160. this.$Toast(tips);
  161. }
  162. }).catch(err => {
  163. uni.hideLoading();
  164. this.$Toast(err.message)
  165. })
  166. },
  167. // 图片上传成功
  168. onSuccess(data){
  169. this.imgUpload = data.result
  170. },
  171. // 移除图片
  172. closeImg() {
  173. this.imgUpload = ''
  174. },
  175. // token 失效
  176. onErrorInfo(data) {
  177. console.log(data)
  178. if(data.code == 401){
  179. this.$tools.navigateTo({
  180. url: '/pages/login/login'
  181. })
  182. }
  183. },
  184. // 下拉刷新
  185. illnessList() {
  186. if(this.isLock) {
  187. if(this.total !== null && this.pageNo * this.pageSize >= this.total){
  188. this.isLock = false;
  189. this.$Toast('没有更多数据了哦!');
  190. setTimeout(()=>{
  191. this.isLock = true;
  192. },3000)
  193. return
  194. }
  195. this.pageNo+=1;
  196. this.getRightListGoods();
  197. }
  198. },
  199. // 根据商品id获取地址
  200. selectUser () {
  201. this.$tools.navigateTo({
  202. url: `/pagesA/my_other_list/prescription/select_medicine_man/index?type=${this.type}&goodsId=${this.goodsId}`
  203. });
  204. },
  205. // 线下确诊疾病 -> 点击添加的疾病
  206. offlinediagnosisList(index=0) {
  207. // index 0 为普通列表 1为搜素
  208. const params = {
  209. pageNo: this.pageNo,
  210. pageSize: this.pageSize,
  211. }
  212. if(index == 1){
  213. params.name = this.keyword
  214. delete params.pageNo
  215. }
  216. uni.showLoading();
  217. this.$api('offlinediagnosisList',params).then(res => {
  218. let { code, result, message} = res;
  219. if(code == 200) {
  220. if(this.total == null) {
  221. this.total = result.total
  222. }
  223. if(index == 1){
  224. this.showList = result.records
  225. }else{
  226. this.showList = this.showList.concat(result.records)
  227. }
  228. uni.hideLoading()
  229. }else {
  230. uni.hideLoading()
  231. this$Toast(message)
  232. }
  233. }).catch(err => {
  234. uni.hideLoading()
  235. this$Toast(err.message)
  236. })
  237. },
  238. // 预约
  239. confirm () {
  240. console.log(this.address)
  241. console.log(this.createOrderType)
  242. const params = {
  243. userId: this.address.id,//用药人标识
  244. goodId: this.goodsId,
  245. confirmatoryDiseaseLabel: this.selectList.toString(), // 确证疾病标签
  246. isAdverse: this.checked?1:0, //1有不良反应
  247. casePic: this.imgUpload, //病例图片
  248. paterId: this.patterId
  249. // caseText: , // 病例信息
  250. }
  251. if(params.confirmatoryDiseaseLabel == '') {
  252. this.$Toast('请选择疾病标签');
  253. return
  254. }
  255. const that = this
  256. this.$api('offlineAdd',params).then(res => {
  257. let { code, result, message} = res;
  258. if(code == 200) {
  259. // 兑购2 拼团1
  260. if(this.createOrderType === 'shoppingCart'){
  261. this.addCart(result)
  262. }else if(this.createOrderType === 'confirm') {
  263. this.setOrder(result.id)
  264. }else {
  265. that.addCart(result);
  266. }
  267. }else {
  268. this.$Toast(message)
  269. }
  270. }).catch(err => {
  271. this.$Toast(err.message)
  272. })
  273. },
  274. // 创建订单
  275. setOrder(id){
  276. const params = {type: this.payType,prescriptionId: this.address.id , offlineInfoId: id, id: this.goodsId, goodsPrice: this.price, goodsNum: this.num, goodsSku: this.goodSkuParam, orderType: this.orderType,paterId: this.patterId}
  277. if(this.preventionId){
  278. params.preventionId = this.preventionId
  279. }
  280. this.$api('teamCreateOrder', params)
  281. .then(res => {
  282. uni.hideLoading()
  283. let { code, message, result } = res
  284. if (code === 200) {
  285. this.$tools.navigateTo({
  286. url: `/pagesC/confirmOrder/confirmOrder?ids=${result.order.id}&orderType=${this.orderType}&payType=${this.payType}&isZone=${this.isZone}`
  287. })
  288. }else if(res.code === 902) {
  289. // 防疫药
  290. uni.showModal({
  291. title: res.message,
  292. success: (res) => {
  293. console.log(res)
  294. if(res.confirm) {
  295. uni.navigateTo({
  296. url: `/pagesB/epidemicPrevention/index?goodsId=${this.goodsId}&orderType=${this.orderType}&num=${this.num}&price=${this.price}&goodSkuParam=${this.goodSkuParam}&prescriptionId=${this.address.id}&medicineMan=${JSON.stringify(this.address)}&createOrderType=${this.createOrderType}&payType=${this.payType}&offlineInfoId=${id}`
  297. })
  298. }
  299. }
  300. })
  301. }else {
  302. this.$Toast(message)
  303. }
  304. })
  305. },
  306. // 加入购物车
  307. addCart(result) {
  308. console.log(this.address)
  309. // type: 2,
  310. const params = {offlineInfoId: result.id ,id: this.goodsId, num: this.num, price: this.price, goodSkuParam: this.goodSkuParam, prescriptionId: this.address.id,paterId: this.patterId }
  311. if(this.preventionId) {
  312. params.preventionId = this.preventionId
  313. }
  314. this.$api('addShoppingCart', params)
  315. .then(res => {
  316. if (res.code === 200) {
  317. uni.$emit('isUpdataShowToast')
  318. this.$Toast(res.message)
  319. let pages_url = getCurrentPages();
  320. const index = pages_url.findIndex(item => {
  321. return item.route == 'pagesC/goodsInfo/goodsInfo'
  322. });
  323. const length = pages_url.length
  324. // 需要返回的层数
  325. const backIndex = length - (index+1);
  326. uni.navigateBack({
  327. delta: backIndex
  328. })
  329. // setTimeout(() => {
  330. // this.$tools.switchTab({
  331. // url: '/pages/shoppingCart/shoppingCart'
  332. // }, 800)
  333. // })
  334. }else if(res.code === 902) {
  335. // 防疫药
  336. uni.showModal({
  337. title: res.message,
  338. success: (res) => {
  339. console.log(res)
  340. if(res.confirm) {
  341. uni.navigateTo({
  342. url: `/pagesB/epidemicPrevention/index?goodsId=${this.goodsId}&num=${this.num}&price=${this.price}&goodSkuParam=${this.goodSkuParam}&prescriptionId=${this.address.id}&medicineMan=${JSON.stringify(this.address)}&offlineInfoId=${result.id}`
  343. })
  344. }
  345. }
  346. })
  347. }else {
  348. this.$Toast(message)
  349. }
  350. }).catch(err => {
  351. this.$Toast(err.message)
  352. })
  353. },
  354. selectDisease (item, index) {
  355. if(new Set(this.selectList).has(item)) {
  356. const index_ = this.selectList.indexOf(item);
  357. this.selectList.splice(index_,1);
  358. }else {
  359. this.selectList.push(item)
  360. }
  361. },
  362. handleDisease (item) {
  363. this.diseaseList.unshift(item.name)
  364. this.diseaseList = [...new Set(this.diseaseList)]
  365. this.show = false
  366. },
  367. }
  368. }
  369. </script>
  370. <style lang="scss" scoped>
  371. .hint_pic{
  372. display: flex;
  373. flex-direction: column;
  374. margin-right: 40rpx;
  375. /deep/.u-list-item {
  376. margin: 0;
  377. width: 232rpx !important;
  378. height: 232rpx !important;
  379. border-radius: 12rpx;
  380. .u-preview-image{
  381. width: 264rpx;
  382. height: 232rpx;
  383. }
  384. image {
  385. width: 232rpx;
  386. height: 232rpx;
  387. }
  388. }
  389. image {
  390. width: 232rpx;
  391. height: 232rpx;
  392. border-radius: 12rpx;
  393. }
  394. }
  395. .confirm-subscribe {
  396. padding: 20rpx 20rpx 140rpx;
  397. &-item {
  398. padding: 20rpx;
  399. background: #ffffff;
  400. border-radius: 18rpx;
  401. box-shadow: 0px 4rpx 6rpx 0px rgba(0,0,0,0.16);
  402. margin-bottom: 40rpx;
  403. &-tag {
  404. padding: 0 20rpx;
  405. height: 50rpx;
  406. background: #E2E2E2;
  407. color: #1d1d1d;
  408. border-radius: 24rpx;
  409. &--active {
  410. background: #baebfc;
  411. color: #01aeea;
  412. }
  413. }
  414. }
  415. &-footer {
  416. z-index: 1;
  417. height: 120rpx;
  418. bottom: 0;
  419. left: 0;
  420. width: 100%;
  421. background: #fff;
  422. /deep/.u-btn {
  423. width: 660rpx;
  424. height: 80rpx;
  425. }
  426. }
  427. &-scroll {
  428. height: calc(50vh - 120rpx );
  429. &-item {
  430. border-bottom: 2rpx solid #D2D2D2;
  431. }
  432. }
  433. }
  434. </style>