| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190 |
- <template>
- <view>
- <!--prescription/drugUsersList/index.wxml-->
- <view class="drugUsers bgfff r20" v-if="pageList.length>0">
- <view>用药人</view>
- <view v-for="(item, index) in pageList" :key="index" class="dflex li">
- <image :src="item.isDefault == 1? '/pages/images/gou_h.png' : '/pages/images/gou.png'" class="check" v-if="!query.isChoose"></image>
- <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>
- <view class="info flex dflex" :data-index="index" @tap="chooseAddress">
- <view class="name">{{item.name}}<text v-if="item.tel">{{item.tel}}</text></view>
- <!-- <view class="addr"><text wx:if="{{item.isDefault == 1}}">默认</text>{{item.address}}{{item.house}}</view> -->
- <!-- <view class="authentication">已认证</view> -->
- <view class="relationship" v-if="item.label">{{item.label}}</view>
- </view>
- <navigator hover-class="none" :url="'/prescription/drugUsers/index?id=' + item.id">
- <image src="/static/pages/images/bjico.png" class="edit"></image>
- </navigator>
- </view>
- </view>
- <view class="nodata nosp" v-if="ishow">
- <image :src="picUrlss+'empty_dd.png'"></image>
- <text>暂无用药人</text>
- </view>
- <view class="bot fixed bgfff dflex" :style="'padding: ' + (bottomBlankHeight + 20) + 'rpx 0rpx'">
- <view class="mbglinear gmbtn" @tap="goUrl" data-url="prescription/drugUsers/index?add=2">添加</view>
- </view>
- </view>
- </template>
- <script>
- // prescription/drugUsersList/index.js
- const app = getApp();
- const req = require("../../utils/request.js");
- export default {
- data() {
- return {
- picUrlss: req.public.picUrls,
- pageList: [],
- bottomBlankHeight: app.globalData.isIPhoneX ? 68 : 0,
- from: {
- page: 1,
- limit: 10
- },
- isLoad: true,
- drugUsers: "",
- choice: false,
- ishow: false
- };
- },
- components: {},
- props: {},
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- this.query = options;
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- this.isLoad = true;
- this.from.page = 1;
- this.getList();
- },
- onReachBottom() {
- this.form.page++;
- this.getList();
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {},
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {},
- methods: {
- goUrl(e) {
- let url = e.currentTarget.dataset.url;
- app.globalData.openPage(url);
- },
- switchTab(event) {
- let index = event.currentTarget.dataset.index;
- let def = this.TabList.findIndex(it => it.active || it.actives);
- let d = {};
- // console.log(def, index);
- d['TabList[' + def + '].active'] = false;
- d['TabList[' + index + '].active'] = true;
- d['pageList'] = []; // this.data.form.states=this.data.TabList[index].state.toString();
- // this.data.form.state = this.data.TabList[index].state;
- this.setData(d);
- },
- chooseAddress(event) {
- const index = event.currentTarget.dataset.index;
- const page = this.pageList[index];
- let that = this;
- if (this.query.choice) {
- let pages = getCurrentPages();
- var prevPage = pages[pages.length - 2];
- prevPage.$vm.setData({
- drugUsers: page,
- choice: true
- });
- uni.navigateBack();
- } // }
- // //设置默认地址
- // req.postRequest('/api/address/set/default', {
- // id: page.id
- // }, () => {
- // let def = that.data.pageList.findIndex(it => it.isDefault == 1);
- // let d = {};
- // if (def > -1) {
- // d['pageList[' + def + '].isDefault'] = 0;
- // }
- // d['pageList[' + index + '].isDefault'] = 1;
- // that.setData(d);
- // })
- // }
- },
- getList() {
- let isShowLoading = false;
- if (this.from.page == 1 && !isShowLoading) {
- req.loadIng('加载中');
- isShowLoading = true;
- }
- let that = this;
- // console.log(that.isLoad);
- if (!that.isLoad) {
- this.setData({
- isLoad: false
- });
- return false;
- }
- that.isLoad = false;
- let from = this.from;
- req.getRequest('/api/userDrugPeople/list', from, data => {
- // console.log(data);
- if (data && data.length == 10) this.isLoad = true;
- if (that.from.page > 1) data = that.pageList.concat(data);
- this.setData({
- pageList: data
- });
- if (this.pageList.length <= 0) {
- let pages = getCurrentPages();
- var prevPage = pages[pages.length - 2];
- prevPage.$vm.setData({
- drugUsers: '',
- choice: false
- });
- that.setData({
- ishow: true
- });
- } else {
- that.setData({
- ishow: false
- });
- }
- if (isShowLoading) {
- uni.hideLoading();
- isShowLoading = false;
- }
- });
- }
- }
- };
- </script>
- <style>
- @import "./index.css";
- </style>
|