cardHolder.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  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. <view class="content3 flex">
  30. <view class="left">
  31. <view class="top flex-row-center">
  32. <image src="../../static/uni.png" mode="widthFix" class="img"></image>
  33. </view>
  34. <view class="bottom flex flex-evenly">
  35. <uni-icons type="home" size="20"></uni-icons>
  36. <text>默</text>
  37. <uni-icons type="redo" size="20"></uni-icons>
  38. </view>
  39. </view>
  40. <view class="right">
  41. <view class="row1 flex">
  42. <text>张三</text>
  43. <text class="line"></text>
  44. <text>总经理</text>
  45. </view>
  46. <view class="row2">
  47. 北京xxx有限公司
  48. </view>
  49. <view class="row3" @click="toMap">
  50. <uni-icons type="redo" size="20"></uni-icons>
  51. <text>北京市朝阳区幸福大街8号</text>
  52. </view>
  53. <view class="row3">
  54. <uni-icons type="redo" size="20"></uni-icons>
  55. <text>13333333333</text>
  56. </view>
  57. <view class="row3">
  58. <uni-icons type="redo" size="20"></uni-icons>
  59. <text>我是备注</text>
  60. </view>
  61. </view>
  62. </view>
  63. <u-picker :show="isShowType" :columns="typeColumns" keyName="label" title="选择分类" @close="isShowType=false"
  64. @cancel="isShowType=false" closeOnClickOverlay @confirm="typeConfirm"></u-picker>
  65. <lyuan-tx-asr ref="asr" :uploadMethod="uploadFile" @change="asrChange" @fileChange="fileChange" appId=""
  66. secretId="" secretKey=""></lyuan-tx-asr>
  67. </view>
  68. </template>
  69. <script>
  70. export default {
  71. data() {
  72. return {
  73. searchVal: '',
  74. isShowType: false,
  75. typeName: '',
  76. typeColumns: [
  77. [{
  78. label: '重要客户',
  79. id: 2021
  80. }, {
  81. label: '常用客户',
  82. id: 804
  83. },
  84. {
  85. label: '次要客户',
  86. id: 804
  87. }
  88. ]
  89. ]
  90. };
  91. },
  92. onShow() {
  93. if (uni.getStorageSync("userInfo")) {
  94. this.userInfo = uni.getStorageSync("userInfo")
  95. this.init()
  96. } else {
  97. this.login()
  98. }
  99. this.searchVal = uni.getStorageSync("search_val") ? uni.getStorageSync("search_val") : ''
  100. },
  101. methods: {
  102. init(){
  103. },
  104. login() {
  105. let that = this
  106. uni.login({
  107. "provider": "weixin",
  108. success: function(wxres) {
  109. that.$request.baseRequest('commonUserApp', 'commonUserLogin', {
  110. loginType: 1,
  111. raw: JSON.stringify(wxres)
  112. }, failres => {
  113. this.$refs.uToast.show({
  114. type: 'error',
  115. message: failres.errmsg,
  116. })
  117. uni.hideLoading()
  118. }).then(res => {
  119. uni.getUserInfo({
  120. provider: 'weixin',
  121. success: function(info) {
  122. console.log(info)
  123. res.data.nickname = info.userInfo.nickName
  124. res.data.head = info.userInfo.avatarUrl
  125. that.$request.baseRequest('commonUserApp', 'edit', {
  126. commonUserInfo: JSON.stringify(res.data)
  127. }, failres => {
  128. this.$refs.uToast.show({
  129. type: 'error',
  130. message: failres.errmsg,
  131. })
  132. uni.hideLoading()
  133. }).then(res1 => {
  134. uni.setStorageSync("userInfo",res1.data)
  135. })
  136. }
  137. })
  138. })
  139. },
  140. fail: function(err) {
  141. // 登录授权失败
  142. // err.code是错误码
  143. }
  144. })
  145. },
  146. toNotice() {
  147. uni.navigateTo({
  148. url: "/pages/cardHolder/notice"
  149. })
  150. },
  151. micOpen: function() {
  152. this.$refs.asr.show();
  153. },
  154. asrChange: function(res) {
  155. console.log('语音识别确认结果:' + res);
  156. },
  157. fileChange: function({
  158. file,
  159. content
  160. }) {
  161. console.log('录音文件', file);
  162. },
  163. uploadFile: function(tempFilePath) {
  164. return new Promise((resolve, reject) => {
  165. //调用你的接口把音频文件转为文字
  166. this.$minApi.upload('txasr/SentenceRecognition', null, tempFilePath)
  167. .then(res => {
  168. if (res.code == 1) {
  169. resolve(res.data.Result);
  170. } else {
  171. reject(e);
  172. }
  173. })
  174. .catch(e => {
  175. reject(e);
  176. });
  177. });
  178. },
  179. search() {
  180. uni.navigateTo({
  181. url: "/pages/cardHolder/search"
  182. })
  183. },
  184. input(res) {
  185. console.log('----input:', res)
  186. },
  187. clear(res) {
  188. uni.showToast({
  189. title: 'clear事件,清除值为:' + res.value,
  190. icon: 'none'
  191. })
  192. },
  193. blur(res) {
  194. uni.showToast({
  195. title: 'blur事件,输入值为:' + res.value,
  196. icon: 'none'
  197. })
  198. },
  199. focus(e) {
  200. uni.showToast({
  201. title: 'focus事件,输出值为:' + e.value,
  202. icon: 'none'
  203. })
  204. },
  205. cancel(res) {
  206. uni.showToast({
  207. title: '点击取消,输入值为:' + res.value,
  208. icon: 'none'
  209. })
  210. },
  211. selectType() {
  212. this.isShowType = true
  213. },
  214. typeConfirm(val) {
  215. console.log(val.value)
  216. this.typeName = val.value[0].label
  217. this.isShowType = false
  218. },
  219. scan() {
  220. // console.log(1)
  221. uni.scanCode({
  222. success: function(res) {
  223. console.log('条码类型:' + res.scanType);
  224. console.log('条码内容:' + res.result);
  225. }
  226. });
  227. },
  228. toMap() {
  229. uni.navigateTo({
  230. url: "/pages/cardHolder/map"
  231. })
  232. },
  233. }
  234. }
  235. </script>
  236. <style lang="scss" scoped>
  237. .content {
  238. padding: 0 20rpx;
  239. }
  240. .u-nav-slot {
  241. /deep/.u-badge {
  242. position: absolute;
  243. top: 0;
  244. right: 6rpx;
  245. }
  246. }
  247. .content1 {
  248. margin-top: 20rpx;
  249. .search {
  250. margin-left: 20rpx;
  251. border: 1px solid #ccc;
  252. border-radius: 50rpx;
  253. width: 100%;
  254. padding: 10rpx 30rpx;
  255. box-sizing: border-box;
  256. .left {
  257. .search-val {
  258. margin-left: 30rpx;
  259. }
  260. }
  261. }
  262. }
  263. .content2 {
  264. .all-type {
  265. }
  266. }
  267. .content3 {
  268. border: 1px solid #ccc;
  269. border-radius: 30rpx;
  270. padding: 40rpx;
  271. box-sizing: border-box;
  272. .left {
  273. width: 30%;
  274. .top {
  275. margin-bottom: 20rpx;
  276. }
  277. .img {
  278. width: 80%;
  279. }
  280. .bottom {
  281. }
  282. }
  283. .right {
  284. .row1 {
  285. .line {
  286. width: 1px;
  287. height: 20px;
  288. margin: 0 20rpx;
  289. background: black;
  290. }
  291. }
  292. }
  293. }
  294. </style>