index.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <template>
  2. <view>
  3. <!--prescription/drugUsersList/index.wxml-->
  4. <view class="drugUsers bgfff r20" v-if="pageList.length>0">
  5. <view>用药人</view>
  6. <view v-for="(item, index) in pageList" :key="index" class="dflex li">
  7. <image :src="item.isDefault == 1? '/pages/images/gou_h.png' : '/pages/images/gou.png'" class="check" v-if="!query.isChoose"></image>
  8. <image :src="item.isDefault == 1 &&query.isChoose? '/pages/images/gou_h.png' : '/pages/images/gou.png'" class="check" @tap="switchTab" :data-index="index" v-else></image>
  9. <view class="info flex dflex" :data-index="index" @tap="chooseAddress">
  10. <view class="name">{{item.name}}<text v-if="item.tel">{{item.tel}}</text></view>
  11. <!-- <view class="addr"><text wx:if="{{item.isDefault == 1}}">默认</text>{{item.address}}{{item.house}}</view> -->
  12. <!-- <view class="authentication">已认证</view> -->
  13. <view class="relationship" v-if="item.label">{{item.label}}</view>
  14. </view>
  15. <navigator hover-class="none" :url="'/prescription/drugUsers/index?id=' + item.id">
  16. <image src="/static/pages/images/bjico.png" class="edit"></image>
  17. </navigator>
  18. </view>
  19. </view>
  20. <view class="nodata nosp" v-if="ishow">
  21. <image :src="picUrlss+'empty_dd.png'"></image>
  22. <text>暂无用药人</text>
  23. </view>
  24. <view class="bot fixed bgfff dflex" :style="'padding: ' + (bottomBlankHeight + 20) + 'rpx 0rpx'">
  25. <view class="mbglinear gmbtn" @tap="goUrl" data-url="prescription/drugUsers/index?add=2">添加</view>
  26. </view>
  27. </view>
  28. </template>
  29. <script>
  30. // prescription/drugUsersList/index.js
  31. const app = getApp();
  32. const req = require("../../utils/request.js");
  33. export default {
  34. data() {
  35. return {
  36. picUrlss: req.public.picUrls,
  37. pageList: [],
  38. bottomBlankHeight: app.globalData.isIPhoneX ? 68 : 0,
  39. from: {
  40. page: 1,
  41. limit: 10
  42. },
  43. isLoad: true,
  44. drugUsers: "",
  45. choice: false,
  46. ishow: false
  47. };
  48. },
  49. components: {},
  50. props: {},
  51. /**
  52. * 生命周期函数--监听页面加载
  53. */
  54. onLoad: function (options) {
  55. this.query = options;
  56. },
  57. /**
  58. * 生命周期函数--监听页面显示
  59. */
  60. onShow: function () {
  61. this.isLoad = true;
  62. this.from.page = 1;
  63. this.getList();
  64. },
  65. onReachBottom() {
  66. this.form.page++;
  67. this.getList();
  68. },
  69. /**
  70. * 生命周期函数--监听页面隐藏
  71. */
  72. onHide: function () {},
  73. /**
  74. * 生命周期函数--监听页面卸载
  75. */
  76. onUnload: function () {},
  77. methods: {
  78. goUrl(e) {
  79. let url = e.currentTarget.dataset.url;
  80. app.globalData.openPage(url);
  81. },
  82. switchTab(event) {
  83. let index = event.currentTarget.dataset.index;
  84. let def = this.TabList.findIndex(it => it.active || it.actives);
  85. let d = {};
  86. // console.log(def, index);
  87. d['TabList[' + def + '].active'] = false;
  88. d['TabList[' + index + '].active'] = true;
  89. d['pageList'] = []; // this.data.form.states=this.data.TabList[index].state.toString();
  90. // this.data.form.state = this.data.TabList[index].state;
  91. this.setData(d);
  92. },
  93. chooseAddress(event) {
  94. const index = event.currentTarget.dataset.index;
  95. const page = this.pageList[index];
  96. let that = this;
  97. if (this.query.choice) {
  98. let pages = getCurrentPages();
  99. var prevPage = pages[pages.length - 2];
  100. prevPage.$vm.setData({
  101. drugUsers: page,
  102. choice: true
  103. });
  104. uni.navigateBack();
  105. } // }
  106. // //设置默认地址
  107. // req.postRequest('/api/address/set/default', {
  108. // id: page.id
  109. // }, () => {
  110. // let def = that.data.pageList.findIndex(it => it.isDefault == 1);
  111. // let d = {};
  112. // if (def > -1) {
  113. // d['pageList[' + def + '].isDefault'] = 0;
  114. // }
  115. // d['pageList[' + index + '].isDefault'] = 1;
  116. // that.setData(d);
  117. // })
  118. // }
  119. },
  120. getList() {
  121. let isShowLoading = false;
  122. if (this.from.page == 1 && !isShowLoading) {
  123. req.loadIng('加载中');
  124. isShowLoading = true;
  125. }
  126. let that = this;
  127. // console.log(that.isLoad);
  128. if (!that.isLoad) {
  129. this.setData({
  130. isLoad: false
  131. });
  132. return false;
  133. }
  134. that.isLoad = false;
  135. let from = this.from;
  136. req.getRequest('/api/userDrugPeople/list', from, data => {
  137. // console.log(data);
  138. if (data && data.length == 10) this.isLoad = true;
  139. if (that.from.page > 1) data = that.pageList.concat(data);
  140. this.setData({
  141. pageList: data
  142. });
  143. if (this.pageList.length <= 0) {
  144. let pages = getCurrentPages();
  145. var prevPage = pages[pages.length - 2];
  146. prevPage.$vm.setData({
  147. drugUsers: '',
  148. choice: false
  149. });
  150. that.setData({
  151. ishow: true
  152. });
  153. } else {
  154. that.setData({
  155. ishow: false
  156. });
  157. }
  158. if (isShowLoading) {
  159. uni.hideLoading();
  160. isShowLoading = false;
  161. }
  162. });
  163. }
  164. }
  165. };
  166. </script>
  167. <style>
  168. @import "./index.css";
  169. </style>