eat.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510
  1. <template>
  2. <view style="height: 100%;">
  3. <!-- <web-view src="../../static/index.html"></web-view> -->
  4. <uni-card style="height: 80%;">
  5. <uni-section title="会员信息" type="line">
  6. <template v-slot:right>
  7. <uni-icons @click="openPopup" type="help" size="17"></uni-icons>
  8. </template>
  9. <uni-forms :modelValue="formData">
  10. <uni-forms-item label="姓名">
  11. <uni-easyinput disabled type="text" v-model="formData.lrXm" placeholder="请输入姓名" />
  12. </uni-forms-item>
  13. <uni-forms-item label="类别" required>
  14. <!-- <uni-data-select v-model="formData.xflb" :localdata="xflbOptions"></uni-data-select> -->
  15. <uni-data-checkbox :disabled="disabled" v-model="formData.xflb" :localdata="xflbOptions"
  16. @change="lbChange"></uni-data-checkbox>
  17. </uni-forms-item>
  18. <uni-forms-item v-if="formData.xflb == '0'" label="套餐" required>
  19. <!-- <uni-data-select v-model="formData.xftc" :localdata="tcOptions"></uni-data-select> -->
  20. <uni-data-picker placeholder="请选择套餐" popup-title="请选择套餐" :localdata="tcOptions"
  21. v-model="formData.tcId" @nodeclick="jg">
  22. </uni-data-picker>
  23. </uni-forms-item>
  24. <uni-forms-item v-if="formData.xflb == '1'" label="金额" required>
  25. <uni-easyinput type="number" v-model="formData.ycje" placeholder="请输入消费金额" @blur="jg" />
  26. </uni-forms-item>
  27. <uni-forms-item v-if="formData.xflb == '0'" label="总价">
  28. <uni-easyinput disabled type="text" v-model="formData.zj" placeholder="请输入总价" />
  29. </uni-forms-item>
  30. <uni-forms-item label="折后价">
  31. <uni-easyinput disabled type="text" v-model="formData.zhj" placeholder="请输入折后价" />
  32. </uni-forms-item>
  33. <uni-button type="primary" @click="submit">提交</uni-button>
  34. </uni-forms>
  35. </uni-section>
  36. </uni-card>
  37. <uni-popup ref="popup" type="center">
  38. <scroll-view>
  39. <view class="jsBox">
  40. <image class="jsImg" src="../../static/images/tcbj.png"></image>
  41. <view class="jsText">
  42. <text class="jsTitle">结算记账流程</text>
  43. <text class="jstext">1.请工作人员采集会员清晰的人像信息</text>
  44. <text class="jstext">2.如未能匹配会员信息请重新采集人像信息或重新维护会员信息</text>
  45. <text class="jstext">3.如识别出多人信息请输入身份证后四位验证真正会员信息</text>
  46. <text class="jstext">4.类别选套餐或自定义金额</text>
  47. <text class="jstext">5.选择相应套餐或输入自定义金额</text>
  48. <text class="jstext">6.系统自动计算折后价</text>
  49. <text class="jstext">7.点击提交按钮完成结算记账</text>
  50. </view>
  51. <view class="jsBtn" @click="closePopup">我知道了</view>
  52. </view>
  53. </scroll-view>
  54. </uni-popup>
  55. <uni-popup ref="popup1" type="dialog">
  56. <uni-transition ref="ani" custom-class="transition" :mode-class="modeClass" :styles="styles" :show="show">
  57. <uni-popup-dialog mode="input" title="身份验证" placeholder="请输入身份证后四位" :maxlength="4" :duration="2000"
  58. :before-close="true" @close="close" @confirm="confirm"></uni-popup-dialog>
  59. </uni-transition>
  60. </uni-popup>
  61. </view>
  62. </template>
  63. </view>
  64. </template>
  65. <script>
  66. import {
  67. getToken,
  68. getUser
  69. } from '@/common/auth.js'
  70. import {
  71. translate,
  72. base64ToUrl
  73. } from '@/common/image.js'
  74. import config from '@/config.js';
  75. import {
  76. CheckZjhm,
  77. TcList,
  78. GetJg,
  79. SaveYcxx
  80. } from '@/api/kh.js'
  81. export default {
  82. data() {
  83. return {
  84. show: true,
  85. modeClass: 'fade',
  86. styles: {},
  87. // 字典
  88. dicts: {
  89. // 结算方式
  90. JC002: []
  91. },
  92. disabled: false,
  93. formData: {
  94. jmZjhm: '',
  95. lrXm: '',
  96. xflb: '',
  97. tcId: '',
  98. jg: '',
  99. zj: '',
  100. ycje: '',
  101. zhj: '',
  102. },
  103. tcOptions: [],
  104. xflbOptions: [],
  105. // 身份证号加密
  106. idcardMD5: '',
  107. userInfo: {},
  108. khInfo: {},
  109. // 人像base64
  110. face: '',
  111. // 组id
  112. groupId: '',
  113. // 人像地址
  114. src: "/static/images/head.png",
  115. // 百度云access_token
  116. token: '',
  117. client_id: config.face_client_id,
  118. client_secret: config.face_client_secret,
  119. khParam: {
  120. ids: "",
  121. id: ""
  122. }
  123. }
  124. },
  125. watch: {
  126. 'dicts.JC002': function(val, oldVal) {
  127. this.zuzhuang()
  128. }
  129. },
  130. onLoad() {
  131. this.getDictList(Object.keys(this.dicts), this.dicts)
  132. },
  133. beforeMount() {},
  134. mounted() {
  135. this.userInfo = getUser()
  136. this.groupId = this.userInfo.dept.locationCode.substring(0, 6)
  137. this.tcList()
  138. // this.start()
  139. this.getKhInfo()
  140. },
  141. onReady() {},
  142. methods: {
  143. lbChange() {
  144. this.formData.zj = ''
  145. this.formData.zhj = ''
  146. this.formData.tcId = ''
  147. this.formData.ycje = ''
  148. },
  149. submit() {
  150. // 0套餐 1现金
  151. if (this.formData.xflb == '0') {
  152. this.formData.ycje = this.formData.zj
  153. }
  154. this.formData.yhje = this.formData.ycje - this.formData.zhj
  155. this.formData.ssqh = this.userInfo.dept.locationCode
  156. SaveYcxx(this.formData).then(res => {})
  157. },
  158. jg(e) {
  159. // 0套餐 1现金
  160. if (this.formData.xflb == '0') {
  161. this.formData.zj = e.dj
  162. this.formData.jg = this.formData.zj
  163. } else {
  164. this.formData.jg = this.formData.ycje
  165. }
  166. uni.showLoading({
  167. title: '计算价格中...'
  168. })
  169. GetJg(this.formData).then(res => {
  170. uni.hideLoading()
  171. this.formData.zhj = res.data.jg
  172. })
  173. },
  174. confirm(e) {
  175. if (e && e.length == 4) {
  176. this.getKhInfo()
  177. this.$refs.popup1.close()
  178. } else {
  179. this.$refs.ani.step({
  180. translateX: '10px',
  181. scale: 1
  182. }, {
  183. timingFunction: 'linear',
  184. duration: 150
  185. })
  186. this.$refs.ani.step({
  187. translateX: '-10px',
  188. scale: 1
  189. }, {
  190. timingFunction: 'linear',
  191. duration: 150
  192. })
  193. this.$refs.ani.step({
  194. translateX: '0px',
  195. scale: 1
  196. }, {
  197. timingFunction: 'linear',
  198. duration: 150
  199. })
  200. this.$refs.ani.run()
  201. }
  202. },
  203. close() {
  204. uni.switchTab({
  205. url: '../index/index'
  206. })
  207. },
  208. zuzhuang() {
  209. if (this.userInfo.jsfs) {
  210. let jsfs = this.userInfo.jsfs.split(",")
  211. if (jsfs.length == 1) this.disabled = true
  212. if (jsfs.length > 0) this.formData.xflb = jsfs[0]
  213. this.dicts.JC002.filter(dic => jsfs.some(fs => {
  214. if (dic.value == fs) {
  215. this.xflbOptions.push({
  216. text: dic.text,
  217. value: dic.value
  218. })
  219. }
  220. }))
  221. }
  222. },
  223. openPopup() {
  224. this.$refs.popup.open()
  225. },
  226. closePopup() {
  227. this.$refs.popup.close()
  228. },
  229. start() {
  230. this.takePhoto()
  231. },
  232. tcList() {
  233. TcList({
  234. jgId: this.userInfo.jgId
  235. }).then(res => {
  236. res.rows.forEach(e => {
  237. this.tcOptions.push({
  238. value: e.id,
  239. text: e.mc,
  240. dj: e.dj,
  241. })
  242. })
  243. })
  244. },
  245. takePhoto() {
  246. uni.chooseImage({
  247. count: 1,
  248. mediaType: ['image'],
  249. sizeType: ['compressed'],
  250. sourceType: ['camera'],
  251. success: (res) => {
  252. uni.showLoading({
  253. title: '正在识别中...'
  254. })
  255. let size = res.tempFiles[0].size
  256. let scale = 1
  257. if (size / 1024 / 1024 > 0.9) scale = 0.4
  258. translate(res.tempFilePaths[0], scale, 'blob', this.setSrc)
  259. },
  260. fail: (err) => {
  261. console.log(err);
  262. }
  263. })
  264. },
  265. setSrc(e, blobUrl) {
  266. this.src = blobUrl
  267. uni.getFileInfo({
  268. filePath: blobUrl,
  269. success: (res) => {
  270. let size = res.size
  271. let scale = 1
  272. if (size / 1024 / 1024 > 0.4) {
  273. scale = 0.6
  274. translate(this.src, scale, 'blob', this.setSrc)
  275. } else {
  276. e = e.replace('data:image/jpeg;base64,', "");
  277. this.face = e
  278. this.getAccessToken()
  279. }
  280. },
  281. fail: (err) => {
  282. console.log(err);
  283. }
  284. })
  285. },
  286. getAccessToken() {
  287. uni.request({
  288. url: '/baiduApi/oauth/2.0/token',
  289. data: {
  290. grant_type: 'client_credentials',
  291. client_id: this.client_id,
  292. client_secret: this.client_secret
  293. },
  294. method: 'POST',
  295. header: {
  296. 'Content-Type': 'application/x-www-form-urlencoded'
  297. },
  298. success: (res) => {
  299. if (res.statusCode == 200) {
  300. this.token = res.data.access_token
  301. this.faceSearch()
  302. } else {
  303. uni.showToast({
  304. icon: 'none',
  305. title: '人像识别异常,请稍后重试'
  306. })
  307. uni.hideLoading()
  308. }
  309. },
  310. error: (err) => {
  311. uni.hideLoading()
  312. }
  313. })
  314. },
  315. // 人脸搜索
  316. faceSearch() {
  317. let face = this.face
  318. let data = {
  319. image: face,
  320. image_type: 'BASE64',
  321. group_id_list: this.groupId,
  322. match_threshold: config.score,
  323. max_user_num: 50
  324. }
  325. uni.request({
  326. url: '/baiduApi/rest/2.0/face/v3/search?access_token=' + this.token,
  327. data: data,
  328. method: 'POST',
  329. header: {
  330. 'Content-Type': 'application/json'
  331. },
  332. success: (res) => {
  333. if (res.data.error_msg == 'SUCCESS') {
  334. // this.isSearch = true
  335. if (res.data.result.user_list.length < 1) {
  336. uni.showModal({
  337. title: '提示',
  338. content: "未找到该会员信息,请重新采集人像",
  339. confirmText: '确定',
  340. success: function(res) {
  341. uni.switchTab({
  342. url: '../index/index'
  343. })
  344. }
  345. })
  346. } else {
  347. let idcards = []
  348. res.data.result.user_list.forEach(e => {
  349. idcards.push(e.user_id)
  350. })
  351. this.khParam.ids = idcards.join(',')
  352. if (res.data.result.user_list.length > 1) {
  353. this.$refs.popup1.open()
  354. uni.hideLoading()
  355. } else {
  356. this.getKhInfo()
  357. }
  358. }
  359. } else {
  360. uni.showModal({
  361. title: '提示',
  362. content: "未找到该人员信息,请重新采集人像",
  363. showCancel: false,
  364. confirmText: '确定',
  365. success: function(res) {
  366. uni.switchTab({
  367. url: '../index/index'
  368. })
  369. }
  370. })
  371. }
  372. },
  373. error: (err) => {
  374. uni.hideLoading()
  375. }
  376. })
  377. },
  378. getKhInfo() {
  379. this.khParam = {
  380. "ids": "a49a68acfc35635d5a30d3a17ec86415",
  381. // "ids": "a49a68acfc35635d5a30d3a17ec86415,a49a68acfc35635d5a30d3a17ec86414,a49a68acfc35635d5a30d3a17ec86413",
  382. "id": ""
  383. }
  384. CheckZjhm(this.khParam).then(res => {
  385. if (res.data.msg == '匹配成功') {
  386. this.khInfo = JSON.parse(res.data.lr)
  387. this.formData.lrXm = this.khInfo.lrXm
  388. this.formData.jmZjhm = this.khInfo.lrJmzjhm
  389. uni.hideLoading()
  390. } else {
  391. uni.showModal({
  392. title: '提示',
  393. content: "未找到该人员信息,请重新采集人像",
  394. showCancel: false,
  395. confirmText: '确定',
  396. success: function(res) {
  397. uni.switchTab({
  398. url: '../index/index'
  399. })
  400. }
  401. })
  402. }
  403. })
  404. },
  405. }
  406. }
  407. </script>
  408. <style scoped>
  409. .jsBox {
  410. width: 90vw;
  411. min-height: 55vh;
  412. /* position: absolute;
  413. top: 0;
  414. left: 0;
  415. z-index: 1; */
  416. }
  417. .jsImg {
  418. width: 100%;
  419. height: 100%;
  420. position: absolute;
  421. top: 0;
  422. left: 0;
  423. z-index: 1;
  424. }
  425. .jsText {
  426. width: 90%;
  427. position: absolute;
  428. left: 5%;
  429. top: 5%;
  430. z-index: 2;
  431. }
  432. .jsTitle {
  433. font-size: 20px;
  434. font-weight: bold;
  435. text-align: center;
  436. /* width: 100%; */
  437. display: block;
  438. color: #000000;
  439. margin-bottom: 5vh;
  440. }
  441. .jstext {
  442. font-size: 16px;
  443. font-weight: 400;
  444. color: #666666;
  445. line-height: 4vh;
  446. text-align: left;
  447. display: block;
  448. }
  449. .jsBtn {
  450. width: 30%;
  451. position: absolute;
  452. left: 35%;
  453. bottom: 3%;
  454. z-index: 3;
  455. text-align: center;
  456. background: linear-gradient(148deg, #FFD334 0%, #F59A02 100%);
  457. box-shadow: 0px 2px 5px 0px rgba(245, 154, 2, 0.4);
  458. border-radius: 5vw;
  459. color: #fff;
  460. font-size: 16px;
  461. font-weight: 400;
  462. line-height: 5vh;
  463. }
  464. /* #ifndef APP-NVUE */
  465. .transition {
  466. display: flex;
  467. justify-content: center;
  468. align-items: center;
  469. width: 100px;
  470. height: 100px;
  471. border-radius: 5px;
  472. text-align: center;
  473. background-color: #4cd964;
  474. box-shadow: 0 0 5px 1px rgba(0, 0, 0, 0.2);
  475. }
  476. /* #endif */
  477. .text {
  478. font-size: 14px;
  479. color: #fff;
  480. }
  481. </style>