cardHolder.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  1. <template>
  2. <view class="content">
  3. <u-navbar title="电子名片" placeholder>
  4. <view class="u-nav-slot relative" slot="left">
  5. <u-icon name="bell" size="26" @click="toNotice"></u-icon>
  6. <u-badge :isDot="true" type="error" class="point"></u-badge>
  7. </view>
  8. </u-navbar>
  9. <view class="content1 flex-row-center">
  10. <view class="col flex">
  11. <uni-icons type="scan" size="30" @click="scan"></uni-icons>
  12. </view>
  13. <view class="search flex flex-between" @click="search">
  14. <view class="left flex">
  15. <uni-icons type="search" size="24"></uni-icons>
  16. <text class="search-val"> {{searchVal?searchVal:'搜索名片'}}</text>
  17. </view>
  18. <view class="right">
  19. <uni-icons type="mic" size="24" @click.stop="micOpen"></uni-icons>
  20. </view>
  21. </view>
  22. </view>
  23. <view class="content2">
  24. <view class="all-type flex" @click="selectType">
  25. <text>{{typeName?typeName:'全部分类'}}</text>
  26. <uni-icons type="bottom" size="20"></uni-icons>
  27. </view>
  28. </view>
  29. <!-- <u-skeleton
  30. :animate="true"
  31. rows="3"
  32. title
  33. :loading='loading'
  34. ></u-skeleton> -->
  35. <mescroll-body v-if='cardHolderList' :up="upOption" ref="mescrollRef" @init="mescrollInit" @up="upCallback" @down="downCallback">
  36. <view v-for='item in cardHolderList' class="content3 flex">
  37. <view class="left">
  38. <view class="top flex-row-center">
  39. <image :src="item.cardManagementInfo.headSculpture" mode="widthFix" class="img"></image>
  40. </view>
  41. <view class="bottom flex flex-evenly">
  42. <uni-icons type="home" size="20"></uni-icons>
  43. <text @click='switchType(item)'>{{item.classify?item.classifyName:'默'}}</text>
  44. <uni-icons type="redo" size="20"></uni-icons>
  45. </view>
  46. </view>
  47. <view class="right">
  48. <view class="row1 flex">
  49. <text>{{item.cardManagementInfo.name}}</text>
  50. <text class="line"></text>
  51. <text>{{item.cardManagementInfo.post}}</text>
  52. </view>
  53. <view class="row2">
  54. {{item.cardManagementInfo.companyName}}
  55. </view>
  56. <view class="row3" @click="toMap">
  57. <uni-icons type="redo" size="20"></uni-icons>
  58. <text>{{item.cardManagementInfo.province}}{{item.cardManagementInfo.city}}{{item.cardManagementInfo.area}}{{item.cardManagementInfo.detailedAddress}}</text>
  59. </view>
  60. <view class="row3">
  61. <uni-icons type="redo" size="20"></uni-icons>
  62. <text>{{item.cardManagementInfo.phone}}</text>
  63. </view>
  64. <view class="row3">
  65. <uni-icons type="redo" size="20"></uni-icons>
  66. <text>我是备注</text>
  67. </view>
  68. </view>
  69. </view>
  70. </mescroll-body>
  71. <u-picker :show="isShowType" :columns="typeColumns" keyName="circleName" title="选择分类" @close="isShowType=false"
  72. @cancel="isShowType=false" closeOnClickOverlay @confirm="typeConfirm"></u-picker>
  73. <lyuan-tx-asr ref="asr" :uploadMethod="uploadFile" @change="asrChange" @fileChange="fileChange" appId=""
  74. secretId="" secretKey=""></lyuan-tx-asr>
  75. <u-toast ref="uToast"></u-toast>
  76. </view>
  77. </template>
  78. <script>
  79. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  80. export default {
  81. mixins: [MescrollMixin],
  82. data() {
  83. return {
  84. searchVal: '',
  85. isShowType: false,
  86. loading:true,
  87. typeName: '',
  88. typeColumns: [],
  89. cardHolderList:[],
  90. currectData:[],
  91. type:1
  92. };
  93. },
  94. onShow() {
  95. if (uni.getStorageSync("userInfo")) {
  96. this.userInfo = uni.getStorageSync("userInfo")
  97. this.init()
  98. } else {
  99. this.login()
  100. }
  101. this.searchVal = uni.getStorageSync("search_val") ? uni.getStorageSync("search_val") : ''
  102. },
  103. methods: {
  104. switchType(item){
  105. this.type=2
  106. this.currectData=item
  107. this.isShowType=true
  108. },
  109. typeConfirm(e){
  110. if(this.type==2){
  111. this.currectData.classify=e.value[0].circleName
  112. this.$request.baseRequest('admin.unimall.cardHolderInfo', 'update',{
  113. cardHolderInfo:JSON.stringify(this.currectData),
  114. }, failres => {
  115. console.log('res+++++', failres.errmsg)
  116. this.$refs.uToast.show({
  117. type: 'error',
  118. message: failres.errmsg,
  119. })
  120. }).then(res => {
  121. this.mescroll.resetUpScroll()
  122. })
  123. }else{
  124. this.typeName = e.value[0].circleName
  125. }
  126. this.isShowType = false
  127. },
  128. init(){
  129. this.$request.baseRequest('admin.unimall.cardClassifyInfo', 'list',{
  130. page:1,
  131. limit:9999,
  132. commonId:uni.getStorageSync("userInfo").id
  133. }, failres => {
  134. console.log('res+++++', failres.errmsg)
  135. this.$refs.uToast.show({
  136. type: 'error',
  137. message: failres.errmsg,
  138. })
  139. }).then(res => {
  140. this.typeColumns=[res.data.items]
  141. this.mescroll.resetUpScroll()
  142. console.log(this.typeColumns)
  143. })
  144. },
  145. upCallback(page){
  146. var that = this
  147. uni.showLoading({
  148. title: '数据加载中'
  149. })
  150. this.$request.baseRequest('admin.unimall.cardHolderInfo', 'list',{
  151. page:page.num,
  152. limit:page.size,
  153. commonId:uni.getStorageSync("userInfo").id
  154. }, failres => {
  155. console.log('res+++++', failres.errmsg)
  156. this.$refs.uToast.show({
  157. type: 'error',
  158. message: failres.errmsg,
  159. })
  160. uni.hideLoading()
  161. }).then(res => {
  162. console.log(res)
  163. if(page.num == 1) this.cardHolderList = [];
  164. let curPageLen = res.data.items.length;
  165. let totalPage = res.data.total;
  166. for (var i = 0; i < res.data.items.length; i++) {
  167. if(res.data.items[i].classify){
  168. res.data.items[i].classifyName=res.data.items[i].classify[0]
  169. }
  170. }
  171. this.cardHolderList=res.data.items
  172. this.loading=false
  173. // if(res.data.items.length>0){
  174. // for(var i=0;i<res.data.items.length;i++){
  175. // res.data.items[i].name=res.data.items[i].circleName[0]
  176. // }
  177. // var itemIndex=res.data.items.findIndex((item)=>{return item.topMarking==1})
  178. // if(itemIndex!=-1){
  179. // var data=res.data.items.splice(itemIndex,1)
  180. // if(page.num==1){
  181. // data.push({circleName:'默认分类',name:'默'})
  182. // }
  183. // res.data.items=data.concat(res.data.items)
  184. // }else{
  185. // if(page.num==1){
  186. // res.data.items=[{circleName:'默认分类',name:'默'}].concat(res.data.items)
  187. // }
  188. // }
  189. // this.cardTypeList=this.cardTypeList.concat(res.data.items)
  190. // }else{
  191. // if(page.num==1){
  192. // this.cardTypeList=[{circleName:'默认分类',name:'默'}]
  193. // }
  194. // }
  195. this.$nextTick(() => {
  196. console.log(that)
  197. // mescroll.endSuccess(data.result);
  198. that.mescroll.endBySize(curPageLen, totalPage)
  199. });
  200. // if (res.errno == 200) {
  201. uni.hideLoading()
  202. // }
  203. })
  204. },
  205. login() {
  206. let that = this
  207. uni.login({
  208. "provider": "weixin",
  209. success: function(wxres) {
  210. that.$request.baseRequest('commonUserApp', 'commonUserLogin', {
  211. loginType: 1,
  212. raw: JSON.stringify(wxres)
  213. }, failres => {
  214. this.$refs.uToast.show({
  215. type: 'error',
  216. message: failres.errmsg,
  217. })
  218. uni.hideLoading()
  219. }).then(res => {
  220. uni.getUserInfo({
  221. provider: 'weixin',
  222. success: function(info) {
  223. console.log(info)
  224. res.data.nickname = info.userInfo.nickName
  225. res.data.head = info.userInfo.avatarUrl
  226. that.$request.baseRequest('commonUserApp', 'edit', {
  227. commonUserInfo: JSON.stringify(res.data)
  228. }, failres => {
  229. this.$refs.uToast.show({
  230. type: 'error',
  231. message: failres.errmsg,
  232. })
  233. uni.hideLoading()
  234. }).then(res1 => {
  235. uni.setStorageSync("userInfo",res1.data)
  236. })
  237. }
  238. })
  239. })
  240. },
  241. fail: function(err) {
  242. // 登录授权失败
  243. // err.code是错误码
  244. }
  245. })
  246. },
  247. toNotice() {
  248. uni.navigateTo({
  249. url: "/pages/cardHolder/notice"
  250. })
  251. },
  252. micOpen: function() {
  253. this.$refs.asr.show();
  254. },
  255. asrChange: function(res) {
  256. console.log('语音识别确认结果:' + res);
  257. },
  258. fileChange: function({
  259. file,
  260. content
  261. }) {
  262. console.log('录音文件', file);
  263. },
  264. uploadFile: function(tempFilePath) {
  265. return new Promise((resolve, reject) => {
  266. //调用你的接口把音频文件转为文字
  267. this.$minApi.upload('txasr/SentenceRecognition', null, tempFilePath)
  268. .then(res => {
  269. if (res.code == 1) {
  270. resolve(res.data.Result);
  271. } else {
  272. reject(e);
  273. }
  274. })
  275. .catch(e => {
  276. reject(e);
  277. });
  278. });
  279. },
  280. search() {
  281. uni.navigateTo({
  282. url: "/pages/cardHolder/search"
  283. })
  284. },
  285. input(res) {
  286. console.log('----input:', res)
  287. },
  288. clear(res) {
  289. uni.showToast({
  290. title: 'clear事件,清除值为:' + res.value,
  291. icon: 'none'
  292. })
  293. },
  294. blur(res) {
  295. uni.showToast({
  296. title: 'blur事件,输入值为:' + res.value,
  297. icon: 'none'
  298. })
  299. },
  300. focus(e) {
  301. uni.showToast({
  302. title: 'focus事件,输出值为:' + e.value,
  303. icon: 'none'
  304. })
  305. },
  306. cancel(res) {
  307. uni.showToast({
  308. title: '点击取消,输入值为:' + res.value,
  309. icon: 'none'
  310. })
  311. },
  312. selectType() {
  313. this.isShowType = true
  314. },
  315. scan() {
  316. // console.log(1)
  317. uni.scanCode({
  318. success: function(res) {
  319. console.log('条码类型:' + res.scanType);
  320. console.log('条码内容:' + res.result);
  321. }
  322. });
  323. },
  324. toMap() {
  325. uni.navigateTo({
  326. url: "/pages/cardHolder/map"
  327. })
  328. },
  329. }
  330. }
  331. </script>
  332. <style lang="scss" scoped>
  333. .content {
  334. padding: 0 20rpx;
  335. }
  336. .u-nav-slot {
  337. /deep/.u-badge {
  338. position: absolute;
  339. top: 0;
  340. right: 6rpx;
  341. }
  342. }
  343. .content1 {
  344. margin-top: 20rpx;
  345. .search {
  346. margin-left: 20rpx;
  347. border: 1px solid #ccc;
  348. border-radius: 50rpx;
  349. width: 100%;
  350. padding: 10rpx 30rpx;
  351. box-sizing: border-box;
  352. .left {
  353. .search-val {
  354. margin-left: 30rpx;
  355. }
  356. }
  357. }
  358. }
  359. .content2 {
  360. .all-type {
  361. }
  362. }
  363. .content3 {
  364. border: 1px solid #ccc;
  365. border-radius: 30rpx;
  366. padding: 40rpx;
  367. box-sizing: border-box;
  368. .left {
  369. width: 30%;
  370. .top {
  371. margin-bottom: 20rpx;
  372. }
  373. .img {
  374. width: 80%;
  375. }
  376. .bottom {
  377. }
  378. }
  379. .right {
  380. .row1 {
  381. .line {
  382. width: 1px;
  383. height: 20px;
  384. margin: 0 20rpx;
  385. background: black;
  386. }
  387. }
  388. }
  389. }
  390. </style>