selectCustom.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456
  1. <!--
  2. 客户选择页面,供开单、回填、红包及计算器等业务选择客户。
  3. 在保留原单选跳转行为的基础上,为红包发送增加多选确认模式。
  4. -->
  5. <template>
  6. <view class="app-main app-content">
  7. <view class="input-wrap_box">
  8. <view>
  9. <AppSearchModule placeholder="输入拼音首字母搜索" @input="searchFn"/>
  10. </view>
  11. </view>
  12. <block v-if="!$util.isEmpty(list.data)">
  13. <block v-for="(item, index) in list.data" :key="index">
  14. <tui-list-cell :arrow="!isHbMulti" @click="selectCurrent(item)">
  15. <view class="tui-msg-box">
  16. <view v-if="isHbMulti" class="multi-checkbox" :class="{ checked: isSelected(item) }">
  17. <text v-if="isSelected(item)">✓</text>
  18. </view>
  19. <image :src="item.avatar" class="tui-msg-pic" mode="aspectFill"/>
  20. <view class="tui-msg-item" style="position:relative;">
  21. <view class="tui-msg-name">
  22. <view class="tui-user-name">
  23. {{ item.name }}
  24. </view>
  25. </view>
  26. <view class="tui-msg-content">
  27. <text>{{ item.visitTime.substr(5,11) }}</text>
  28. <text v-if="Number(item.balance)!=0" class="balance-amount">
  29. <text v-if="item.balance>0" class="amount_add">余额{{item.balance?parseFloat(item.balance):0}}</text>
  30. <text v-else class="amount_sub">欠款{{item.balance?Math.abs(parseFloat(item.balance)):0}}</text>
  31. </text>
  32. <text v-if="item.overTimeUnExpend && item.overTimeUnExpend == 10000" style="font-size:24upx;margin-left:20upx;color:green;">没有下过单</text>
  33. <text v-if="item.overTimeUnExpend && item.overTimeUnExpend == 7" style="font-size:24upx;margin-left:20upx;color:green;">超1周未下单</text>
  34. <text v-if="item.overTimeUnExpend && item.overTimeUnExpend == 30" style="font-size:24upx;margin-left:20upx;color:green;">超1个月未下单</text>
  35. <text v-if="item.overTimeUnExpend && item.overTimeUnExpend == 180" style="font-size:24upx;margin-left:20upx;color:green;">超半年未下单</text>
  36. <text v-if="item.overTimeUnExpend && item.overTimeUnExpend == 365" style="font-size:24upx;margin-left:20upx;color:green;">超1年未下单</text>
  37. </view>
  38. </view>
  39. </view>
  40. <view class="tui-msg-right">
  41. <badge-module type="danger" :dot="item.level == 3 ? true : false" v-if="item.messageNum > 0" >{{ item.messageNum }}</badge-module >
  42. </view>
  43. </tui-list-cell>
  44. </block>
  45. </block>
  46. <block v-else>
  47. <app-wrapper-empty :is-empty="$util.isEmpty(list.data)" />
  48. </block>
  49. <view v-if="isHbMulti" class="multi-footer">
  50. <button class="confirm-multi-btn" @click="confirmMulti">确定(已选{{ selectedCount }}人)</button>
  51. </view>
  52. </view>
  53. </template>
  54. <script>
  55. import TuiListCell from "@/components/plugin/list-cell";
  56. import BadgeModule from "@/components/plugin/badge";
  57. import AppWrapperEmpty from "@/components/app-wrapper-empty";
  58. import appVipModule from "@/components/module/app-vip";
  59. import AppTag from "@/components/module/app-tag.vue";
  60. import AppSearchModule from "@/components/module/app-search";
  61. import { list } from "@/mixins";
  62. import { getList } from "@/api/member";
  63. import { mapGetters } from "vuex";
  64. export default {
  65. name: "selectCustom",
  66. components: {
  67. TuiListCell,
  68. BadgeModule,
  69. AppWrapperEmpty,
  70. appVipModule,
  71. AppTag,
  72. AppSearchModule
  73. },
  74. mixins: [list],
  75. data() {
  76. return {
  77. tabIndex: 0,
  78. selectStyle: 1,
  79. option: {},
  80. selectedMap: {},
  81. couldScan: false
  82. };
  83. },
  84. computed:{
  85. ...mapGetters(["getMyShopInfo"]),
  86. /**
  87. * 判断是否为红包客户多选模式,style=5 未带 multi 时继续走旧单选流程。
  88. */
  89. isHbMulti() {
  90. return String(this.option.style) === '5' && String(this.option.multi) === '1'
  91. },
  92. /**
  93. * 返回当前已选客户数量,供底部按钮实时展示。
  94. */
  95. selectedCount() {
  96. return Object.keys(this.selectedMap).length
  97. }
  98. },
  99. onPullDownRefresh() {
  100. this.resetList();
  101. this._list().then((res) => {
  102. uni.stopPullDownRefresh();
  103. });
  104. },
  105. onReachBottom() {
  106. if (!this.list.finished) {
  107. this._list().then((res) => {
  108. uni.stopPullDownRefresh();
  109. });
  110. } else {
  111. uni.stopPullDownRefresh();
  112. }
  113. },
  114. onLoad(option) {
  115. this.option = option || {}
  116. // #ifdef APP-PLUS
  117. if(plus.device.vendor == 'Newland'){
  118. this.couldScan = true
  119. }
  120. // #endif
  121. },
  122. onShow(){
  123. uni.removeStorageSync('newClient');
  124. },
  125. methods: {
  126. /**
  127. * 处理客户选择;红包多选只切换选中状态,其余场景保持原跳转或回填逻辑。
  128. */
  129. selectCurrent(item,scanEnv=0){
  130. let style = this.option.style != null && this.option.style !== '' ? this.option.style : 1
  131. this.selectStyle = style
  132. if (this.isHbMulti) {
  133. this.toggleSelected(item)
  134. return
  135. }
  136. if(style == 1){
  137. //花材开单
  138. this.$util.pageTo({url: '/admin/billing/index2?customId='+item.id+'&customName='+item.name,type:2})
  139. }else if(style == 3){
  140. //花束开单
  141. this.$util.pageTo({url: '/admin/billing/hs?customId='+item.id+'&customName='+item.name,type:2})
  142. }else if(style == 2){
  143. //用于选择客户并且需要返回的情况
  144. let pages = getCurrentPages();
  145. let prevPage = pages[ pages.length - 2 ];
  146. prevPage.$vm.form.customId = item.id;
  147. prevPage.$vm.form.customName = item.name;
  148. prevPage.$vm.form.selectCustomOk = 1;
  149. uni.navigateBack({})
  150. }else if(style == 5){
  151. // 发红包
  152. this.$util.pageTo({url: '/admin/hb/send?userId='+item.userId+'&customId='+item.id+'&customName='+item.name,type:2})
  153. }else if(Number(style) === 6){
  154. /** 工具-计算器选客回填,与 hdApp_calculator_pick_customer 一致(hdApp 零售:3 已用于花束开单,计算器单独用 6) */
  155. try {
  156. uni.setStorageSync('hdApp_calculator_pick_customer', JSON.stringify({ id: item.id, name: item.name }))
  157. } catch (e) {}
  158. uni.navigateBack({})
  159. }else{
  160. //无操作
  161. }
  162. },
  163. /**
  164. * 判断客户是否已在红包多选集合中。
  165. */
  166. isSelected(item) {
  167. return !!this.selectedMap[String(item.id)]
  168. },
  169. /**
  170. * 切换客户选中状态,保存接口提交所需的用户与客户标识。
  171. */
  172. toggleSelected(item) {
  173. const key = String(item.id)
  174. if (this.selectedMap[key]) {
  175. this.$delete(this.selectedMap, key)
  176. return
  177. }
  178. this.$set(this.selectedMap, key, {
  179. id: item.id,
  180. userId: item.userId,
  181. name: item.name,
  182. customId: item.id
  183. })
  184. },
  185. /**
  186. * 将红包多选结果暂存后返回发送页,空选择时提示用户继续选择。
  187. */
  188. confirmMulti() {
  189. const selected = Object.keys(this.selectedMap).map((key) => this.selectedMap[key])
  190. if (!selected.length) {
  191. this.$msg('请至少选择一位客户')
  192. return
  193. }
  194. uni.setStorageSync('hb_selected_customs', JSON.stringify(selected))
  195. uni.navigateBack()
  196. },
  197. init() {
  198. if(!this.no_shop_show_model) {
  199. this._list();
  200. }
  201. },
  202. searchFn(e) {
  203. this.resetList();
  204. this.seekVal = e;
  205. this._list();
  206. },
  207. _list() {
  208. return getList({
  209. search: "",
  210. type:this.tabIndex,
  211. page: this.list.page,
  212. name: this.seekVal,
  213. }).then((res) => {
  214. this.completes(res);
  215. if (this.$util.isEmpty(res.data)){
  216. return false;
  217. }
  218. });
  219. },
  220. change(e) {
  221. if (this.tabIndex == e.index) {
  222. return false;
  223. }
  224. this.tabIndex = e.index;
  225. this.resetList();
  226. this._list();
  227. },
  228. },
  229. };
  230. </script>
  231. <style lang="scss" scoped>
  232. .app-content {
  233. padding-top: 100upx;
  234. padding-bottom: 130upx;
  235. }
  236. .tabs-wrap {
  237. position: fixed;
  238. .tabs-left {
  239. width: 80%;
  240. }
  241. .tabs-right {
  242. width: 19%;
  243. border-left: $borderColor;
  244. @include disFlex(center, center);
  245. }
  246. }
  247. .input-wrap_box {
  248. background-color: #fff;
  249. position: fixed;
  250. top: 0;
  251. z-index: 10;
  252. /* 手机mobile屏幕小于1000px */
  253. @media screen and (max-width: 1100px) {
  254. width: 100%;
  255. }
  256. /* 收银台cashier屏幕大于1000px */
  257. @media screen and (min-width:1100px) {
  258. width: 40%;
  259. }
  260. height: 100upx;
  261. display: flex;
  262. align-items: center;
  263. padding: 0 30upx;
  264. & > view:nth-child(1) {
  265. flex: 1;
  266. }
  267. }
  268. .tui-msg-box {
  269. display: flex;
  270. align-items: center;
  271. .multi-checkbox {
  272. display: flex;
  273. align-items: center;
  274. justify-content: center;
  275. width: 36upx;
  276. height: 36upx;
  277. margin-right: 18upx;
  278. border: 2upx solid #bbb;
  279. border-radius: 6upx;
  280. color: #fff;
  281. font-size: 24upx;
  282. box-sizing: border-box;
  283. &.checked {
  284. border-color: #09c567;
  285. background: #09c567;
  286. }
  287. }
  288. .tui-msg-pic {
  289. width: 80upx;
  290. height: 80upx;
  291. border-radius: 50%;
  292. margin-right: 20upx;
  293. }
  294. .tui-msg-item {
  295. max-width: 500upx;
  296. min-height: 80upx;
  297. overflow: hidden;
  298. display: flex;
  299. flex-direction: column;
  300. justify-content: space-between;
  301. & > div {
  302. @include disFlex(center, flex-start);
  303. & > div:first-child {
  304. margin-right: 8upx;
  305. }
  306. }
  307. .level-img {
  308. ::v-deep.vip-text {
  309. left: 70upx;
  310. top: 8upx;
  311. }
  312. }
  313. .normal-img {
  314. width: 70upx;
  315. padding: 2upx 6upx;
  316. color: #999;
  317. background-color: #f0f2f6;
  318. border-radius: 20upx;
  319. .vip-text {
  320. font-size: 24upx;
  321. transform: scale(0.6);
  322. position: relative;
  323. top: -2upx;
  324. left: -8upx;
  325. }
  326. }
  327. .member-img {
  328. width: 70upx;
  329. padding: 2upx 6upx;
  330. color: green;
  331. background-color: #f0f2f6;
  332. border-radius: 20upx;
  333. .vip-text {
  334. font-size: 24upx;
  335. transform: scale(0.6);
  336. position: relative;
  337. top: -2upx;
  338. left: -8upx;
  339. }
  340. }
  341. .iconfont {
  342. color: #00aaed;
  343. }
  344. }
  345. .tui-msg-name {
  346. overflow: hidden;
  347. white-space: nowrap;
  348. text-overflow: ellipsis;
  349. font-size: 30upx;
  350. line-height: 1;
  351. color: #262b3a;
  352. margin-bottom: 4upx;
  353. .tui-user-name {
  354. overflow: hidden;
  355. text-overflow: ellipsis;
  356. white-space: nowrap;
  357. width: 450upx;
  358. font-size: 34upx;
  359. .super-man{
  360. margin-left:30upx;
  361. color:red;
  362. font-size:24upx;
  363. display:inline-block;
  364. color:white;
  365. border:1upx solid green;
  366. padding:6upx 10upx;
  367. background-color: green;
  368. border-radius: 11upx;
  369. }
  370. .ls-man{
  371. margin-left:30upx;
  372. font-size:24upx;
  373. display:inline-block;
  374. color:white;
  375. border:1upx solid #a5b1a5;
  376. padding:6upx 10upx;
  377. background-color: #a5b1a5;
  378. border-radius: 11upx;
  379. }
  380. }
  381. }
  382. .tui-msg-content {
  383. width:550upx;
  384. overflow: hidden;
  385. white-space: nowrap;
  386. text-overflow: ellipsis;
  387. font-size: 26upx;
  388. color: #9397a4;
  389. .balance-amount{
  390. margin-left:20upx;
  391. .amount_sub{
  392. color:red;
  393. margin-left:6upx;
  394. }
  395. .amount_add{
  396. color:#3385FF;
  397. margin-left:6upx;
  398. }
  399. }
  400. }
  401. }
  402. .tui-msg-right {
  403. max-width: 120upx;
  404. height: 80upx;
  405. margin-left: auto;
  406. margin-right: 24upx;
  407. text-align: right;
  408. display: flex;
  409. justify-content: space-between;
  410. align-items: center;
  411. }
  412. .user_tag {
  413. border: 1upx solid #cccccc;
  414. padding: 5upx 12upx 5upx 12upx;
  415. border-radius: 25upx;
  416. color: #bbbbbb;
  417. margin-right: 10upx;
  418. margin-bottom: 12upx;
  419. display: inline-block;
  420. font-size: 30upx;
  421. }
  422. .multi-footer {
  423. position: fixed;
  424. z-index: 20;
  425. right: 0;
  426. bottom: 0;
  427. left: 0;
  428. padding: 20upx 30upx;
  429. background: #fff;
  430. box-shadow: 0 -2upx 12upx rgba(0, 0, 0, 0.08);
  431. .confirm-multi-btn {
  432. height: 80upx;
  433. line-height: 80upx;
  434. border-radius: 40upx;
  435. background: #09c567;
  436. color: #fff;
  437. font-size: 30upx;
  438. &::after {
  439. border: none;
  440. }
  441. }
  442. }
  443. </style>