binddealer.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. <template>
  2. <view class="enterprise-list">
  3. <view class="list-wrap">
  4. <u-sticky bgColor="#fff" class="main-sticky">
  5. <view class="search-wrap">
  6. <view class="input-wrap">
  7. <view class="input">
  8. <u-search bgColor='#fff' :showAction='false'
  9. :placeholder="$t('base.common.inputPlaceholder')" @search="searchList"
  10. @clear='searchList' v-model="form.keyword">
  11. </u-search>
  12. <view class="search-btn" @click="searchList">{{$t("customer_meter.search")}}</view>
  13. </view>
  14. </view>
  15. </view>
  16. </u-sticky>
  17. <template v-if="driverList.length">
  18. <u-swipe-action>
  19. <view v-for="(item, index) in driverList" :key="item.id" class="business-card">
  20. <!-- <u-swipe-action-item :name="item.userName" :options="options" @click="onVehicleChange($event,item)"> -->
  21. <view class="business-card-info">
  22. <text class="info">{{item.dealerName}}</text>
  23. <text class="no">{{item.dealerPhone}}</text>
  24. <view class="businessStatus-info">
  25. <u--image width="100rpx" height="88rpx"
  26. :src="item.statusFlag==1?'/subpages/static/czzn-img/state/start.png':'/subpages/static/czzn-img/state/stop.png'">
  27. </u--image>
  28. </view>
  29. </view>
  30. <!-- </u-swipe-action-item> -->
  31. </view>
  32. </u-swipe-action>
  33. </template>
  34. <template v-else>
  35. <u-empty mode="list" icon="https://cdn.uviewui.com/uview/empty/list.png">
  36. </u-empty>
  37. </template>
  38. </view>
  39. <u-modal :show="showAdd" @confirm="confirm" ref="addModal" showCancelButton closeOnClickOverlay
  40. @cancel="showAdd=false" @close="showAdd=false">
  41. <view class="invite-box">
  42. <view class="invite-box-title">绑定客商</view>
  43. <u--input placeholder="请输入客商手机号" border="surround" v-model="phone"></u--input>
  44. </view>
  45. </u-modal>
  46. <!-- <uni-fab ref="fab" horizontal="left" vertical="bottom" buttonColor="#3c9cff" @trigger="trigger"
  47. @fabClick="onClickRight" /> -->
  48. </view>
  49. </template>
  50. <script>
  51. import {
  52. getDealerList,
  53. } from "../../api/driver";
  54. import {
  55. getDriverTenantList,
  56. } from "../../api/tenant.js";
  57. export default {
  58. data() {
  59. return {
  60. options: [{
  61. text: this.$t("base.button.disableEnable"),
  62. name: "disable",
  63. style: {
  64. backgroundColor: '#3c9cff'
  65. }
  66. },
  67. // {
  68. // text: this.$t("base.button.delete"),
  69. // name: "delete",
  70. // style: {
  71. // backgroundColor: '#f56c6c'
  72. // }
  73. // }
  74. ],
  75. current: undefined,
  76. showAdd: false,
  77. showEnable: false,
  78. keyword: "",
  79. active: 0,
  80. value: "",
  81. phone: "",
  82. driverList: [],
  83. form: {
  84. keyword: "",
  85. },
  86. tablist: [{
  87. name: this.$t("customer_meter.all"),
  88. },
  89. {
  90. name: this.$t("customer_meter.enable"),
  91. },
  92. {
  93. name: this.$t("customer_meter.deactivate"),
  94. },
  95. ],
  96. page: {
  97. pages: 1,
  98. size: 10,
  99. },
  100. total: 0,
  101. hasMore: true,
  102. };
  103. },
  104. components: {},
  105. onLoad() {
  106. this.bindDealerList();
  107. },
  108. methods: {
  109. //搜索列表
  110. searchList() {
  111. this.page.pages = 1
  112. this.hasMore = false
  113. this.bindDealerList()
  114. },
  115. //显示启用弹窗
  116. onVehicleChange(e, item) {
  117. var that = this;
  118. if (e.index == 0) {
  119. //停用客商
  120. uni.showModal({
  121. content: (item.statusFlag == 1 ? that.$t("dealer.stopDealer") : that.$t(
  122. "dealer.startDealer")),
  123. showCancel: true,
  124. cancelText: that.$t("settings.cancelText"),
  125. confirmText: that.$t("settings.confirmText"),
  126. success: function(res) {
  127. if (res.confirm) {
  128. console.log("开始处理客商信息、", item);
  129. dealerUpdateStatus(item.id, item.statusFlag == 1 ? 0 : 1).then(res => {
  130. if (res.statusCode == 200) {
  131. uni.showToast({
  132. title: (item.statusFlag == 1 ? that.$t(
  133. "dealer.stopIng") : that.$t(
  134. "dealer.startIng")),
  135. icon: "none",
  136. duration: 2000,
  137. });
  138. that.driverList = [];
  139. that.bindDealerList()
  140. }
  141. })
  142. }
  143. }
  144. })
  145. }
  146. // else {
  147. // //删除
  148. // uni.showModal({
  149. // // title: '提示',
  150. // content: that.$t("driver.deleteVehcile"),
  151. // showCancel: true,
  152. // cancelText: that.$t("base.search.cancelText"),
  153. // confirmText: that.$t("base.search.submitText"),
  154. // success: function(r) {
  155. // if (r.confirm) {
  156. // dealerDeleteVehicle(item).then(res => {
  157. // if (res.statusCode == 200) {
  158. // that.bindDealerList()
  159. // }
  160. // })
  161. // }
  162. // }
  163. // })
  164. // }
  165. },
  166. //加载更多
  167. scrolltolower() {
  168. if (this.hasMore) {
  169. this.page.pages += 1;
  170. this.bindDealerList();
  171. }
  172. },
  173. bindDealerList() {
  174. this.form.appUserType="4"
  175. getDealerList(this.form).then((res) => {
  176. if (this.hasMore) {
  177. this.driverList = [
  178. ...this.driverList,
  179. ...res.data.data,
  180. ];
  181. } else {
  182. this.driverList = res.data.data;
  183. }
  184. console.log(this.driverList);
  185. // debugger
  186. this.driverList.forEach((item) => {
  187. item.enableFlag = item.statusFlag == "1" ? true : false;
  188. });
  189. this.total = res.data.data.total;
  190. if (this.driverList.length >= this.total) {
  191. this.hasMore = false;
  192. } else {
  193. this.hasMore = true;
  194. }
  195. });
  196. },
  197. //点击右侧加号
  198. onClickRight() {
  199. this.showAdd = true;
  200. },
  201. changeTab(item) {
  202. this.active = item.index;
  203. },
  204. //绑定客商
  205. confirm() {
  206. bindDealerByPhone({
  207. phone: this.phone
  208. }).then((res) => {
  209. if (res.statusCode == 200) {
  210. console.log("绑定的信息为、",res.data);
  211. if(res.data.code==0 && !res.data.data.tenantList){
  212. uni.setStorageSync('tenantInfo', res.data.data.tenantList)
  213. }
  214. this.dealerPhone = ""
  215. this.showAdd = false
  216. this.driverList = [];
  217. uni.showToast({
  218. title: "绑定成功",
  219. icon: "none",
  220. duration: 2000,
  221. });
  222. this.page.pages = 1;
  223. this.bindDealerList();
  224. } else {
  225. this.dealerPhone = ""
  226. this.showAdd = false
  227. }
  228. });
  229. },
  230. },
  231. };
  232. </script>
  233. <style lang="scss" scoped>
  234. @import '../../common/css/public.scss';
  235. </style>