Vip.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529
  1. <template>
  2. <div>
  3. <div v-if="vip_login === false">
  4. <div class="tip">
  5. 请输入会员手机号查询会员,或输入要办理会员的手机号进行办理
  6. <!-- <p>(若会员未绑定手机号,可通过扫码枪扫描/输入会员码登录会员)</p>-->
  7. </div>
  8. <div class="keyboard">
  9. <div class="keyboard-input keyboard-input-wrapper">
  10. <input
  11. v-model="input"
  12. type="text"
  13. placeholder="输入会员手机号"
  14. autocomplete
  15. spellcheck="false"
  16. class="input-input input-large"
  17. />
  18. </div>
  19. <keyboard @click="numFn"></keyboard>
  20. </div>
  21. </div>
  22. <div v-if="vip_handle === false && vip_login === true" class="change-price">
  23. <div class="vip_title">
  24. <p class="color_size">
  25. <el-button type="text">
  26. {{ input }}
  27. </el-button>
  28. 还不是会员,可快速办理新会员
  29. </p>
  30. <div>
  31. <span style="margin-right: 20px">会员姓名</span>
  32. <span>
  33. <el-input
  34. v-model="vip.name"
  35. clearable
  36. style="width: 26%"
  37. ></el-input>
  38. </span>
  39. </div>
  40. <div>
  41. <span style="margin-right: 20px">会员生日</span>
  42. <span>
  43. <el-date-picker
  44. v-model="vip.birthday"
  45. style="width: 26%"
  46. default-value="1990-01-01"
  47. type="date"
  48. placeholder="选择日期"
  49. format="yyyy-MM-dd"
  50. value-format="timestamp"
  51. ></el-date-picker>
  52. </span>
  53. </div>
  54. <div>
  55. <span style="margin-right: 20px">会员类型</span>
  56. <span>
  57. <el-select
  58. v-model="vip.type"
  59. style="width: 26%"
  60. placeholder="客户类型"
  61. >
  62. <el-option
  63. v-for="item in customerType_list"
  64. :key="item.id"
  65. :label="item.name"
  66. :value="item.id"
  67. ></el-option>
  68. </el-select>
  69. </span>
  70. </div>
  71. </div>
  72. <div class="btn-group" style="bottom: 40px; height: auto">
  73. <el-button @click="vip_login = false">取消</el-button>
  74. <el-button type="primary" @click="addCustomer">确认办理</el-button>
  75. </div>
  76. </div>
  77. <div v-if="vip_handle === true">
  78. <div>
  79. <div
  80. style="
  81. margin: 10px 0 0 10px;
  82. position: relative;
  83. color: #333333;
  84. height: 80px;
  85. "
  86. >
  87. <div style="display: inline-block">
  88. <el-row class="demo-avatar demo-basic">
  89. <el-col :span="12">
  90. <div class="demo-basic--circle">
  91. <div class="block">
  92. <el-avatar
  93. v-if="vip_info.avatar"
  94. :size="50"
  95. :src="vip_info.avatar"
  96. ></el-avatar>
  97. <el-avatar v-else icon="el-icon-user-solid"></el-avatar>
  98. </div>
  99. </div>
  100. </el-col>
  101. </el-row>
  102. </div>
  103. <div
  104. style="
  105. display: inline-block;
  106. margin-left: 20px;
  107. line-height: 20px;
  108. position: absolute;
  109. top: 6px;
  110. "
  111. >
  112. <div>
  113. <span>{{ vip_info.name }}</span>
  114. <span class="vip_name">默认会员</span>
  115. </div>
  116. <div>
  117. {{ vip_info.mobile }}
  118. </div>
  119. </div>
  120. <div style="float: right; margin-right: 20px">
  121. <el-button @click="changeUser">切换会员</el-button>
  122. </div>
  123. </div>
  124. <div class="property">
  125. <!-- <div>-->
  126. <!-- <p class="title">-->
  127. <!-- 余额(元)-->
  128. <!-- </p>-->
  129. <!-- <p class="price">-->
  130. <!-- {{ vip_info.money||'0.00' }}-->
  131. <!-- <span-->
  132. <!-- class="price_text"-->
  133. <!-- @click="reCharge=true"-->
  134. <!-- >充值</span>-->
  135. <!-- </p>-->
  136. <!-- </div>-->
  137. <!-- <div>-->
  138. <!-- <p class="title">-->
  139. <!-- 积分-->
  140. <!-- </p>-->
  141. <!-- <p class="price">-->
  142. <!-- 0-->
  143. <!-- <span-->
  144. <!-- class="price_text"-->
  145. <!-- @click="integral=true"-->
  146. <!-- >充值</span>-->
  147. <!-- </p>-->
  148. <!-- </div>-->
  149. <!-- <div>-->
  150. <!-- <p class="title">-->
  151. <!-- 优惠券-->
  152. <!-- </p>-->
  153. <!-- <p class="price">-->
  154. <!-- 0-->
  155. <!-- </p>-->
  156. <!-- </div>-->
  157. <!-- <div>-->
  158. <!-- <p class="title">-->
  159. <!-- 会员卡-->
  160. <!-- </p>-->
  161. <!-- <p class="price">-->
  162. <!-- 无-->
  163. <!-- </p>-->
  164. <!-- </div>-->
  165. <div>
  166. <p class="title">消费金额(元)</p>
  167. <p class="price">
  168. {{ vip_info.totalPayMoney || "0.00" }}
  169. </p>
  170. </div>
  171. <div>
  172. <p class="title">订单数</p>
  173. <p class="price">
  174. {{ vip_info.orderNum || "0" }}
  175. </p>
  176. </div>
  177. <!-- <div>-->
  178. <!-- <p class="title">-->
  179. <!-- 维权订单数-->
  180. <!-- </p>-->
  181. <!-- <p class="price">-->
  182. <!-- 0-->
  183. <!-- </p>-->
  184. <!-- </div>-->
  185. <!-- <div>-->
  186. <!-- <p class="title">-->
  187. <!-- 退款金额(元)-->
  188. <!-- </p>-->
  189. <!-- <p class="price">-->
  190. <!-- 0-->
  191. <!-- </p>-->
  192. <!-- </div>-->
  193. </div>
  194. <div
  195. style="
  196. height: 62px;
  197. line-height: 62px;
  198. color: #333;
  199. font-weight: bold;
  200. "
  201. >
  202. <p>会员信息</p>
  203. </div>
  204. <div class="member_info">
  205. <el-form :model="vip_info" label-width="120px" size="small">
  206. <el-form-item label="会员注册时间:">
  207. {{ $_common.formatDate(vip_info.createTime) }}
  208. </el-form-item>
  209. <el-form-item label="生日:">
  210. {{ vip_info.birthday?$_common.formatDate(vip_info.birthday*1000,'yyyy-MM-dd'):'&#45;&#45;' }}
  211. </el-form-item>
  212. <el-form-item
  213. v-if="vip_info.defaultAddress.area"
  214. label="默认收货地址:"
  215. >
  216. {{ vip_info.defaultAddress.area.provinceName
  217. }}{{ vip_info.defaultAddress.area.cityName
  218. }}{{ vip_info.defaultAddress.area.districtName
  219. }}{{ vip_info.defaultAddress.address }}
  220. </el-form-item>
  221. <!-- <el-form-item label="备注:">-->
  222. <!-- {{ vip_info.remark||'-' }}-->
  223. <!-- </el-form-item>-->
  224. </el-form>
  225. </div>
  226. </div>
  227. </div>
  228. </div>
  229. </template>
  230. <script>
  231. import Keyboard from "./Keyboard";
  232. import { getCartByUser, searchCustomerDetails } from "@/api/Cashier";
  233. import { getCustomerSourceList } from "@/api/System";
  234. import { addCustomer } from "@/api/Customer";
  235. export default {
  236. name: "Vip",
  237. components: {
  238. Keyboard,
  239. },
  240. props: {
  241. vipLogin: {
  242. type: Boolean,
  243. default: false,
  244. },
  245. vipHandle: {
  246. type: Boolean,
  247. default: false,
  248. },
  249. numList: {
  250. type: Array,
  251. default: () => {
  252. return [];
  253. },
  254. },
  255. nowSelShop: {
  256. type: Object,
  257. default: () => {
  258. return {};
  259. },
  260. },
  261. reCharge: {
  262. type: Boolean,
  263. default: false,
  264. },
  265. collection: {
  266. type: Boolean,
  267. default: false,
  268. },
  269. },
  270. data() {
  271. return {
  272. vip_login: false,
  273. vip_handle: false,
  274. input: "",
  275. customerId: "",
  276. customerName: "",
  277. customerType: "",
  278. userCenterId: "",
  279. vip_info: {
  280. createTime: "",
  281. birthday: "",
  282. price: "",
  283. integral: "",
  284. remarks: "",
  285. defaultAddress: {
  286. area: {
  287. provinceName: "",
  288. cityName: "",
  289. districtName: "",
  290. address: "",
  291. },
  292. },
  293. remark: "",
  294. },
  295. vip: {
  296. type: "",
  297. name: "",
  298. birthday: "",
  299. },
  300. customerType_list: [], // 客户类型列表
  301. };
  302. },
  303. created() {
  304. this.vip_handle = this.vipHandle;
  305. this.vip_login = this.vipLogin;
  306. this.re_charge = this.reCharge;
  307. this.getAllCustomerSource();
  308. },
  309. methods: {
  310. // 请输入会员手机号查询会员
  311. async numFn(e, num) {
  312. if (num !== "x" || num !== "清除" || num !== "确定") {
  313. this.numList.push(num);
  314. }
  315. if (num === "x") {
  316. this.input = this.input.substring(0, this.input.length - 1);
  317. } else if (num === "清除") {
  318. this.input = "";
  319. this.numList = [];
  320. } else if (num === "确定") {
  321. this.searchCustomerDetails();
  322. } else {
  323. this.input += num;
  324. }
  325. },
  326. changeUser() {
  327. this.collection = false;
  328. this.re_charge = false;
  329. this.vip_login = false;
  330. this.vip_handle = false;
  331. this.userCenterId = "";
  332. this.customerId = "";
  333. this.customerName = "";
  334. this.customerType = "";
  335. this.vip_info = {
  336. createTime: "",
  337. birthday: "",
  338. price: "",
  339. integral: "",
  340. remarks: "",
  341. defaultAddress: {
  342. area: {
  343. provinceName: "",
  344. cityName: "",
  345. districtName: "",
  346. address: "",
  347. },
  348. },
  349. remark: "",
  350. };
  351. },
  352. // 查询会员信息
  353. async searchCustomerDetails() {
  354. if (!this.input) {
  355. this.$message.warning("请输入会员手机号");
  356. return;
  357. }
  358. const re = /^1[3456789]\d{9}$/; // 正则表达式
  359. if (!re.test(this.input)) {
  360. this.$message.warning("手机号格式有误,请重新输入!");
  361. return;
  362. }
  363. const data = await searchCustomerDetails({
  364. mobile: this.input,
  365. });
  366. console.log(data.data.userCenterId,'用户id')
  367. if (JSON.stringify(data) === "{}") {
  368. // this.$message.error('未查找到会员信息')
  369. this.vip_handle = false;
  370. this.vip_login = true;
  371. this.userCenterId = "";
  372. this.customerId = "";
  373. this.customerName = "";
  374. this.customerType = "";
  375. this.vip_info = {};
  376. } else {
  377. this.vip_handle = true;
  378. this.vip_login = true;
  379. this.vip_info = data.data;
  380. this.$emit("vipInfo", this.vip_info);
  381. this.userCenterId =data.data.userCenterId;
  382. this.customerId = data.data.customerId;
  383. this.customerName = data.data.name;
  384. this.customerType = data.data.customerType;
  385. this.$emit("getCartByUser", this.userCenterId);
  386. }
  387. },
  388. // 获取客户类型
  389. async getAllCustomerSource() {
  390. if (this.customerType_list.length) {
  391. return;
  392. }
  393. const data = await getCustomerSourceList();
  394. this.customerType_list = data.data;
  395. const defaultData = data.data.find((item) => item.defaultStatus === 5);
  396. if (defaultData) {
  397. this.vip.type = defaultData.id;
  398. } else {
  399. this.vip.type = data.data[0].id;
  400. }
  401. },
  402. // 新增会员
  403. async addCustomer() {
  404. const data = await addCustomer({
  405. birthday: parseInt(this.vip.birthday / 1000),
  406. shopId: this.nowSelShop.id,
  407. mobile: this.input,
  408. name: this.vip.name,
  409. type: this.vip.type,
  410. });
  411. this.searchCustomerDetails();
  412. },
  413. },
  414. };
  415. </script>
  416. <style scoped>
  417. .tip {
  418. font-size: 16px;
  419. color: #666;
  420. width: 580px;
  421. margin: 80px auto 20px;
  422. line-height: 20px;
  423. }
  424. .tip p {
  425. color: #999;
  426. font-size: 14px;
  427. margin: 5px 0;
  428. }
  429. .keyboard {
  430. display: flex;
  431. align-items: center;
  432. flex-direction: column;
  433. }
  434. .keyboard-input {
  435. width: 590px;
  436. height: 60px;
  437. /*margin-left: 296px;*/
  438. position: relative;
  439. text-align: center;
  440. }
  441. .keyboard-input-wrapper {
  442. display: inline-block;
  443. vertical-align: middle;
  444. line-height: normal;
  445. }
  446. .input-input {
  447. height: 60px;
  448. font-size: 18px;
  449. padding: 6px 18px;
  450. display: inline-block;
  451. width: 590px;
  452. border: 1px solid #dcdee2;
  453. border-radius: 4px;
  454. color: #808695;
  455. cursor: text;
  456. }
  457. .change-price {
  458. position: relative;
  459. height: calc(99vh - 130px);
  460. overflow: auto;
  461. }
  462. .change-price .btn-group {
  463. position: absolute;
  464. width: 100%;
  465. bottom: 0;
  466. left: 0;
  467. text-align: right;
  468. }
  469. .vip_title {
  470. color: #333333;
  471. margin-top: 52px;
  472. text-align: center;
  473. font-size: 14px;
  474. }
  475. .color_size {
  476. font-size: 12px;
  477. color: #999;
  478. }
  479. .btn-group {
  480. padding: 10px 20px;
  481. border-top: 1px solid #f2f2f2;
  482. text-align: right;
  483. background-color: #ffffff;
  484. }
  485. .vip_name {
  486. margin-left: 12px;
  487. background: rgb(236, 245, 255);
  488. color: #409eff;
  489. padding: 2px 5px;
  490. font-size: 10px;
  491. }
  492. .property {
  493. height: 106px;
  494. background: #f5f6fa;
  495. border-radius: 4px;
  496. color: #333;
  497. display: flex;
  498. flex-wrap: wrap;
  499. align-items: center;
  500. line-height: 30px;
  501. }
  502. .property div {
  503. width: 25%;
  504. padding-left: 20px;
  505. }
  506. .title {
  507. font-size: 14px;
  508. margin-bottom: 2px;
  509. }
  510. .price {
  511. font-size: 26px;
  512. font-weight: 800;
  513. }
  514. .member_info {
  515. background: #f5f6fa;
  516. padding: 22px;
  517. font-size: 12px;
  518. color: #333;
  519. }
  520. </style>