cardHolder.vue 6.7 KB

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