index.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719
  1. <template>
  2. <view>
  3. <view class="photo">
  4. <block v-if="cardInfo.imageMap">
  5. <image :src="cardInfo.imageMap" mode="aspectFill" class="poster"></image>
  6. <view class="change ddflex" @click="uploadImg()">
  7. <image src="../static/images/sc_ico.png"></image>
  8. 更换形象图
  9. </view>
  10. </block>
  11. <view class="upload ddflex" v-else @click="uploadImg()">
  12. <image src="../static/images/jia.png"></image>
  13. 上传专属形象
  14. </view>
  15. </view>
  16. <view class="infos">
  17. <view class="info ddflex">
  18. <view class="flex">
  19. <view class="company">{{ cardInfo.companyName }}</view>
  20. <view class="name">{{ cardInfo.realName }}</view>
  21. <view class="job">{{ cardInfo.job }}</view>
  22. </view>
  23. <view class="logo">
  24. <image :src="cardInfo.avatar" mode="aspectFit"></image>
  25. </view>
  26. <!-- <view class="logo"><image src="../static/images/wap_logo.png" mode="aspectFit"></image></view> -->
  27. </view>
  28. <view class="btns ddflex" v-if="cardId">
  29. <button open-type="share" hover-class="none" class="share-ta">分享名片</button>
  30. <view class="save" @tap="addContact()">保存到通讯录</view>
  31. </view>
  32. <view class="contacts" v-if="cardId || isShowContacts">
  33. <scroll-view scroll-x="true" class="contact">
  34. <view class="li" @click="goPhone()">
  35. <view class="lit dflex">
  36. <image src="../static/images/phone.png"></image>
  37. 拨打电话
  38. </view>
  39. <view class="num">{{ cardInfo.phone }}</view>
  40. </view>
  41. <view class="li" @click="copy(cardInfo.wechat, 1)">
  42. <view class="lit ddflex">
  43. <image src="../static/images/wechat.png"></image>
  44. 复制微信
  45. </view>
  46. <view class="num">{{ cardInfo.wechat }}</view>
  47. </view>
  48. <view class="li" @click="copy(cardInfo.email, 2)">
  49. <view class="lit ddflex">
  50. <image src="../static/images/message.png"></image>
  51. 复制邮箱
  52. </view>
  53. <view class="num">{{ cardInfo.email }}</view>
  54. </view>
  55. </scroll-view>
  56. </view>
  57. <view :class="'zhan ddflex' + (isShowContacts ? ' zhan-romate' : '')" v-if="!cardId"
  58. @click="showContacts()">
  59. {{ isShowContacts ? '收起' : '展开全部名片信息' }}
  60. <image src="../static/images/bico1.png" class="bico"></image>
  61. </view>
  62. <block v-if="!cardId">
  63. <button open-type="share" hover-class="none" class="share">发名片</button>
  64. <view class="opt ddflex">
  65. <view class="li" @click="jumpUrl('/card/create/create?isEdit=true&id=' + cardInfo.id)">
  66. <image src="../static/images/edit.png"></image>
  67. <view>编辑名片</view>
  68. </view>
  69. <!-- <view class="li">
  70. <image src="../static/images/fx_ico.png"></image>
  71. <view>分享图像名片</view>
  72. </view> -->
  73. <view class="li" @click="jumpUrl('/card/poster/poster?id=' + cardInfo.id)">
  74. <image src="../static/images/code.png"></image>
  75. <view>名片码</view>
  76. </view>
  77. </view>
  78. </block>
  79. <view class="datas ddflex">
  80. <view class="users ddflex fflex">
  81. <!-- <view class="q-users ddflex" v-if="cardInfo.pageUser.list.length > 0">
  82. <image :src="item.avatar" mode="aspectFill" v-for="(item, index) in cardInfo.pageUser.list" v-if="index<3" :key="index"></image>
  83. </view> -->
  84. <view class="fflex">{{ cardInfo.person }}人看过</view>
  85. </view>
  86. <view class="zan ddflex" @click="userBehavior(3)">
  87. <image :src="'../static/images/'+(cardInfo.isThumbs ? 'like_h.png':'zan_ico.png')"></image>
  88. {{ cardInfo.thumbs }}
  89. </view>
  90. <!-- <view class="renqi ddflex">
  91. <image src="../static/images/rqico.png"></image>
  92. {{ cardInfo.viewsNo }}
  93. </view> -->
  94. </view>
  95. </view>
  96. <view class="box brief">
  97. <view class="tit ddflex">
  98. <view class="flex ddflex">
  99. <image src="../static/images/jj_ico.png"></image>
  100. <view>个人简介</view>
  101. </view>
  102. <image v-if="!cardId" src="../static/images/bj_ico.png" class="edit"
  103. @tap="jumpUrl('/card/editDesc/editDesc?id=' + cardInfo.id)"></image>
  104. </view>
  105. <view class="bri"><rich-text :nodes="cardInfo.brief ? cardInfo.brief : '一句话介绍自己'"></rich-text></view>
  106. </view>
  107. <view class="box" v-if="!cardId">
  108. <view class="tit ddflex">
  109. <image src="../static/images/sj_ico.png"></image>
  110. <view>
  111. 名片数据
  112. <text>(人次)</text>
  113. </view>
  114. </view>
  115. <view class="card-datas ddflex">
  116. <view class="li">
  117. <text>{{ cardInfo.todayBrowse }}</text>
  118. 今日访问
  119. </view>
  120. <view class="li">
  121. <text>{{ cardInfo.browse }}</text>
  122. 访问总量
  123. </view>
  124. <view class="li">
  125. <text>{{ cardInfo.share }}</text>
  126. 名片分享
  127. </view>
  128. </view>
  129. </view>
  130. <view class="box videos" v-if="!cardId">
  131. <view class="tit ddflex">
  132. <view class="flex ddflex">
  133. <image src="../static/images/sp_ico.png"></image>
  134. <view>我的视频</view>
  135. </view>
  136. <!-- <image v-if="cardInfo.videoId" @click="uploadVodChangeHandle()" src="../static/images/bj_ico.png" class="edit"></image> -->
  137. <image v-if="cardInfo.videoId" @click="uploadVideo()" src="../static/images/bj_ico.png" class="edit">
  138. </image>
  139. </view>
  140. <view class="video">
  141. <!-- <video v-if="cardInfo.videoId" controls="true" class="video-sp" :src="videoInfo.playUrl"></video> -->
  142. <video v-if="cardInfo.videoId" controls="true" class="video-sp" :src="cardInfo.videoId"></video>
  143. <view v-else class="not" @click="uploadVideo()" v-else>
  144. <image src="../static/images/add_ico1.png"></image>
  145. <view>点击添加个人介绍视频</view>
  146. </view>
  147. </view>
  148. </view>
  149. <block v-else>
  150. <view class="box videos" v-if="cardInfo.videoId">
  151. <view class="tit ddflex">
  152. <view class="flex ddflex">
  153. <image src="../static/images/sp_ico.png"></image>
  154. <view>我的视频</view>
  155. </view>
  156. </view>
  157. <view class="video">
  158. <video controls="true" class="video-sp" :src="cardInfo.videoId"></video>
  159. <!-- <video controls="true" class="video-sp" :src="videoInfo.playUrl"></video> -->
  160. </view>
  161. </view>
  162. </block>
  163. <view class="box pic">
  164. <view class="tit ddflex">
  165. <view class="flex ddflex">
  166. <image src="../static/images/tp_ico.png"></image>
  167. <view>风采展示</view>
  168. </view>
  169. <!-- <image v-if="cardInfo.pictures && !cardId" @click="uploadImgs()" src="../static/images/bj_ico.png" class="edit"></image> -->
  170. <image v-if="cardInfo.pictures && !cardId" @click="jumpUrl('/card/imgList/index?id='+cardInfo.id)"
  171. src="../static/images/bj_ico.png" class="edit"></image>
  172. </view>
  173. <view class="picture">
  174. <view class="pics" v-if="cardInfo.pictures">
  175. <image v-for="(item, index) in getImgList(cardInfo.pictures)" :key="index" :src="item"
  176. mode="widthFix" @tap="previewImg(getImgList(cardInfo.pictures), index)"></image>
  177. </view>
  178. <view class="not" v-else @click="jumpUrl('/card/imgList/index?id='+cardInfo.id)">
  179. <!-- @click="uploadImgs()" -->
  180. <image src="../static/images/add_ico1.png"></image>
  181. <view>点击添加图片</view>
  182. </view>
  183. </view>
  184. </view>
  185. <view class="also" v-if="cardId" @click="jumpUrl('/card/create/create')">我也要创建电子名片</view>
  186. <!-- #ifdef H5 -->
  187. <wx-share ref="wxshare" />
  188. <!-- #endif -->
  189. </view>
  190. </template>
  191. <script>
  192. const app = getApp();
  193. const req = require('../../utils/request.js');
  194. const api = require('../../utils/api.js');
  195. import VODUpload from '@/utils/aliyun-upload-sdk-1.0.1.min.js'
  196. export default {
  197. data() {
  198. return {
  199. options: '',
  200. scene: null,
  201. cardId: '',
  202. cardInfo: '',
  203. cardCount: '',
  204. isShowContacts: true,
  205. zhiPicUrls: [],
  206. isFirst: true, //页面加载第一次调用
  207. uploader: '',
  208. isStart: false,
  209. videoInfo: '',
  210. fileName: '', //视频名称
  211. };
  212. },
  213. onLoad(options) {
  214. this.options = options
  215. this.cardId = options.cardId;
  216. if (options.scene)
  217. this.scene = options.scene
  218. },
  219. async onShow() {
  220. if (this.scene) {
  221. await this.loadCodeParams();
  222. }
  223. console.log('req.isLogins(false)', req.isLogins(false))
  224. // #ifdef H5
  225. req.isLogins(true)
  226. // #endif
  227. // #ifdef APP
  228. await req.silenceLogin(this.options.userId ? this.options.userId : '', '')
  229. // #endif
  230. await this.getCardInfo();
  231. },
  232. onShareAppMessage: function() {
  233. this.saveShareBehavior()
  234. return this.onShareMessage();
  235. },
  236. onShareTimeline() {
  237. this.saveShareBehavior()
  238. return {
  239. title: this.getShareTitle(),
  240. imageUrl: this.cardInfo.imageMap ? this.cardInfo.imageMap : this.cardInfo.avatar,
  241. query: this.getSharePath()
  242. };
  243. },
  244. onReady() {
  245. // #ifdef H5
  246. var that = this;
  247. //初始化分享内容
  248. setTimeout(function() {
  249. var shareContent = that.onShareMessage();
  250. if (shareContent) {
  251. shareContent.path = window.location.origin + shareContent.path;
  252. }
  253. console.log('分享内容》》》》》', shareContent);
  254. that.$refs.wxshare.init(shareContent);
  255. }, 4 * 1000);
  256. // #endif
  257. },
  258. methods: {
  259. saveShareBehavior() {
  260. let params = {
  261. behavior: 6,
  262. type: 23,
  263. bindId: this.cardInfo.id
  264. }
  265. req.saveBehavior(params, res => {})
  266. },
  267. onShareMessage(){
  268. return {
  269. title: this.getShareTitle(),
  270. imageUrl: this.cardInfo.imageMap ? this.cardInfo.imageMap : this.cardInfo.avatar,
  271. path: this.getSharePath()
  272. };
  273. },
  274. addContact: function() {
  275. var that = this;
  276. wx.showActionSheet({
  277. itemList: ['添加联系人'],
  278. success: function(res) {
  279. // 添加到手机通讯录
  280. uni.addPhoneContact({
  281. firstName: that.cardInfo.realName, //联系人姓名
  282. mobilePhoneNumber: that.cardInfo.phone, //联系人手机号
  283. organization: that.cardInfo.companyName, //公司
  284. weChatNumber: that.cardInfo.wechat, //微信
  285. email: that.cardInfo.email, //电子邮件
  286. })
  287. }
  288. })
  289. },
  290. getSharePath() {
  291. let path = '/card/index/index?cardId=' + this.cardInfo.id + '&appId=' + req.getStorage('appId');
  292. return path;
  293. },
  294. getShareTitle() {
  295. let title = this.cardInfo.realName;
  296. return (req.excludeSpecial(req.getStorage('userInfo').nickName) ? req.excludeSpecial(req.getStorage(
  297. 'userInfo').nickName) : '') + '分享了一张' + title + '的名片';
  298. },
  299. loadCodeParams() {
  300. let _ts = this;
  301. return new Promise((resolve, reject) => {
  302. if (!_ts.scene) {
  303. resolve();
  304. return false;
  305. }
  306. req.getRequest(
  307. '/api/code/params', {
  308. scene: _ts.scene
  309. },
  310. data => {
  311. this.options.userId = data.userId
  312. this.cardId = data.scene
  313. resolve();
  314. }
  315. );
  316. });
  317. },
  318. getImgList(url) {
  319. var list = [];
  320. if (url) {
  321. list = url.split(',');
  322. }
  323. return list;
  324. },
  325. jumpUrl(url) {
  326. uni.navigateTo({
  327. url: url
  328. });
  329. },
  330. getCardInfo() {
  331. var url = '';
  332. var dataP = {};
  333. if (this.cardId) {
  334. url = api.card_info;
  335. dataP.id = this.cardId;
  336. } else {
  337. url = api.card_userInfo;
  338. dataP = {};
  339. }
  340. return new Promise((resolve, reject) => {
  341. req.getRequest(url, dataP, data => {
  342. this.cardInfo = data;
  343. // if(this.cardInfo.videoId){
  344. // this.getPlayInfo(this.cardInfo.videoId);
  345. // }
  346. console.log('isFirst')
  347. if (this.cardId && this.cardInfo.userId == req.getStorage('userInfo').id) {
  348. this.cardId = null
  349. this.getCardInfo()
  350. } else {
  351. if (this.cardInfo.userId == req.getStorage('userInfo').id) {
  352. } else {
  353. // 用户浏览
  354. if (this.isFirst) {
  355. this.userBehavior(4)
  356. }
  357. }
  358. this.isFirst = false
  359. }
  360. resolve()
  361. });
  362. })
  363. },
  364. getPlayInfo(videoId) {
  365. req.getRequest('/api/v3/vod/playInfo', {
  366. videoId: videoId
  367. }, data => {
  368. this.videoInfo = data
  369. })
  370. },
  371. // 用户行为
  372. userBehavior(type) {
  373. var dataP = {};
  374. dataP.type =
  375. 23 //、产品 2、活动 3、未知 4、内容 5、课程 6、老师 7、素材 8、题目 9、资料领取 10、招聘职位 12、用户须知 13、素材 15、医院科室 16、海报 20、医生 21 新闻 23名片
  376. dataP.behavior = type; //1、关注 2、收藏 3、点赞 4、浏览 5、确认 6、分享
  377. dataP.bindId = this.cardInfo.id;
  378. req.postRequestLoding('/api/v3/behavior/save', dataP, data => {
  379. if (type == 3) {
  380. if (!this.cardInfo.isThumbs) this.cardInfo.thumbs++;
  381. else this.cardInfo.thumbs--
  382. this.cardInfo.isThumbs = !this.cardInfo.isThumbs
  383. }
  384. if (type == 1) {
  385. this.cardInfo.follow = !this.cardInfo.follow
  386. }
  387. });
  388. },
  389. showContacts() {
  390. this.isShowContacts = !this.isShowContacts;
  391. },
  392. goPhone() {
  393. uni.makePhoneCall({
  394. phoneNumber: this.cardInfo.phone
  395. }); // 传参带入号码即可
  396. },
  397. copy(valueText, type) {
  398. uni.setClipboardData({
  399. data: valueText,
  400. success: function(res) {
  401. if (type == 1) {
  402. req.msg('微信号复制成功');
  403. } else if (type == 2) {
  404. req.msg('邮箱复制成功');
  405. }
  406. }
  407. });
  408. },
  409. createUploader() {
  410. let self = this;
  411. return new VODUpload({
  412. timeout: 60000,
  413. partSize: 1048576,
  414. parallel: 5,
  415. retryCount: 3,
  416. retryDuration: 2,
  417. region: this.regionId,
  418. userId: this.accountId,
  419. // 开始上传
  420. onUploadstarted: function(uploadInfo) {
  421. uni.showLoading({
  422. title: '视频上传中'
  423. })
  424. console.log('uploadInfo==', uploadInfo)
  425. if (!uploadInfo.videoId) {
  426. req.getRequest('/api/v3/vod/uploadAuth?fileName=' + self.fileName, {}, res => {
  427. var data = res;
  428. self.uploader.setUploadAuthAndAddress(uploadInfo, data.uploadAuth, data
  429. .uploadAddress, data.videoId)
  430. })
  431. self.isStart = true;
  432. } else {
  433. req.getRequest('/api/v3/vod/refreshUploadAuth?videoId=' + uploadInfo.videoId, {},
  434. res => {
  435. var data = res;
  436. self.uploader.setUploadAuthAndAddress(uploadInfo, data.uploadAuth, data
  437. .uploadAddress, data.videoId)
  438. })
  439. }
  440. },
  441. // 文件上传成功
  442. onUploadSucceed: function(uploadInfo) {
  443. // req.msg("视频上传成功");
  444. let dataP = {
  445. id: self.cardInfo.id,
  446. videoId: uploadInfo.videoId,
  447. videoInfo: JSON.stringify(uploadInfo)
  448. }
  449. req.postRequest(api.card_saveOrUpdate, dataP, res => {
  450. self.getPlayInfo(uploadInfo.videoId);
  451. setTimeout(() => {
  452. self.isStart = false;
  453. }, 1000);
  454. uni.hideLoading()
  455. })
  456. },
  457. // 文件上传失败
  458. onUploadFailed: function(uploadInfo, code, message) {
  459. req.msg("文件上传失败");
  460. },
  461. // 取消文件上传
  462. onUploadCanceled: function(uploadInfo, code, message) {
  463. req.msg("文件已暂停上传");
  464. },
  465. // 文件上传进度,单位:字节, 可以在这个函数中拿到上传进度并显示在页面上
  466. onUploadProgress: function(uploadInfo, totalSize, progress) {
  467. var progressPercent = Math.ceil(progress * 100);
  468. // self.$set(self.uploader, 'authProgress', progressPercent);
  469. },
  470. // 上传凭证超时
  471. onUploadTokenExpired: function(uploadInfo) {
  472. req.getRequest('/api/v3/vod/refreshUploadAuth?videoId=' + uploadInfo.videoId, {},
  473. res => {
  474. var data = res;
  475. self.uploader.resumeUploadWithAuth(data.uploadAuth)
  476. })
  477. }
  478. })
  479. },
  480. uploadVodChangeHandle: function(e) {
  481. let self = this;
  482. uni.chooseVideo({
  483. count: 1, //上传视频的个数
  484. mediaType: ['video'], //限制上传的类型为video
  485. sourceType: ['album', 'camera'], //视频选择来源
  486. maxDuration: 58, //拍摄限制时间
  487. camera: 'back', //采用后置摄像头
  488. success: function(res) {
  489. //获取临时存放的视频资源
  490. // let tempFilePath=res.tempFiles[0]
  491. console.log('视频文件==', res)
  492. var file = {
  493. url: res.tempFilePath,
  494. coverUrl: res.thumbTempFilePath
  495. };
  496. self.fileName = res.tempFilePath.substring(res.tempFilePath.lastIndexOf('/') + 1)
  497. // if (self.uploader) {
  498. // self.uploader.stopUpload();
  499. // self.authProgress = 0;
  500. // }
  501. var userData = '{"Vod":{}}';
  502. self.uploader = self.createUploader();
  503. self.uploader.addFile(file, null, null, null, userData);
  504. self.uploader.startUpload();
  505. },
  506. })
  507. },
  508. uploadVideo() {
  509. let that = this;
  510. uni.chooseVideo({
  511. sourceType: ['camera', 'album'],
  512. success(res) {
  513. uni.showLoading({
  514. title: '上传中'
  515. })
  516. req.uploadFile(api.upload, res.tempFilePath, res => {
  517. that.updateCard(2, res.src);
  518. uni.hideLoading();
  519. });
  520. }
  521. });
  522. },
  523. uploadImg() {
  524. let that = this;
  525. uni.chooseImage({
  526. count: 1,
  527. sizeType: ['original', 'compressed'],
  528. sourceType: ['album', 'camera'],
  529. success: function({
  530. tempFilePaths
  531. }) {
  532. var promise = Promise.all(
  533. tempFilePaths.map(tempFilePath => {
  534. return new Promise(function(resolve, reject) {
  535. req.uploadFile(api.upload, tempFilePath, res => {
  536. that.imageMap = res.src;
  537. //上传完成,则更新保存
  538. that.updateCard(3, that.imageMap);
  539. });
  540. });
  541. })
  542. );
  543. promise
  544. .then(function(results) {
  545. console.log(results);
  546. })
  547. .catch(function(err) {
  548. console.log(err);
  549. });
  550. }
  551. });
  552. },
  553. uploadImgs() {
  554. let that = this;
  555. uni.chooseImage({
  556. count: 9,
  557. sizeType: ['original', 'compressed'],
  558. sourceType: ['album', 'camera'],
  559. success: function({
  560. tempFilePaths
  561. }) {
  562. uni.showLoading({
  563. title: '上传中'
  564. });
  565. var promise = Promise.all(
  566. tempFilePaths.map(tempFilePath => {
  567. return new Promise(function(resolve, reject) {
  568. req.uploadFile(api.upload, tempFilePath, res => {
  569. let picUrls = that.zhiPicUrls;
  570. that.zhiPicUrls = picUrls.concat(res.src);
  571. if (tempFilePaths.length == that.zhiPicUrls
  572. .length) {
  573. //上传完成,则更新保存
  574. that.updateCard(1, that.zhiPicUrls.join(
  575. ','));
  576. }
  577. uni.hideLoading();
  578. });
  579. });
  580. })
  581. );
  582. promise
  583. .then(function(results) {
  584. console.log(results);
  585. })
  586. .catch(function(err) {
  587. console.log(err);
  588. });
  589. }
  590. });
  591. },
  592. //预览图片
  593. previewImg(picUrls, index) {
  594. //预览合同图片
  595. var src = picUrls[index];
  596. let imgs = picUrls;
  597. uni.previewImage({
  598. current: src, // 当前显示图片的http链接
  599. urls: imgs
  600. });
  601. },
  602. cleanimages(index) {
  603. // 删除图片
  604. let arr = this.zhiPicUrls;
  605. arr.splice(index, 1);
  606. this.zhiPicUrls = arr;
  607. },
  608. /**
  609. * @param {Object} type 1图片 2、视频
  610. * @param {Object} url 资源地址
  611. */
  612. updateCard(type, url) {
  613. var dataP = {};
  614. dataP.id = this.cardInfo.id;
  615. if (type == 1) {
  616. dataP.pictures = url;
  617. } else if (type == 2) {
  618. dataP.videoId = url;
  619. } else if (type == 3) {
  620. dataP.imageMap = url;
  621. }
  622. req.postRequest(api.card_saveOrUpdate, dataP, json => {
  623. if (type == 1) {
  624. this.cardInfo.pictures = url;
  625. this.zhiPicUrls = [];
  626. } else if (type == 2) {
  627. this.cardInfo.videoId = url;
  628. } else if (type == 3) {
  629. this.cardInfo.imageMap = url;
  630. }
  631. });
  632. },
  633. toWxShare() {
  634. req.getWXOriginalId(data => {
  635. if (data) {
  636. this.wxShare(data);
  637. } else {
  638. this.$showModal({
  639. title: '提示',
  640. content: '未配置微信小程序',
  641. cancelText: '取消',
  642. confirmText: '设置开通'
  643. }).then(res => {
  644. // 点击确认的操作
  645. // tha.copy(content);
  646. });
  647. }
  648. });
  649. },
  650. wxShare(originalId) {
  651. //分享H5
  652. // uni.share({
  653. // provider: 'weixin',
  654. // scene: 'WXSceneSession',
  655. // type: 0,
  656. // href: req.env[req.env.NODE_ENV].h5BaseUrl + '/share/card/index?cardId=' + this.cardInfo.id,
  657. // title: this.cardInfo.nickName + ' - 电子名片',
  658. // summary: this.cardInfo.title + ' ' + this.cardInfo.position.name + ' ' + this.cardInfo.message,
  659. // imageUrl: this.cardInfo.avatar,
  660. // success: function(res) {
  661. // console.log('success:' + JSON.stringify(res));
  662. // },
  663. // fail: function(err) {
  664. // console.log('fail:' + JSON.stringify(err));
  665. // }
  666. // });
  667. uni.share({
  668. provider: 'weixin',
  669. scene: 'WXSceneSession',
  670. type: 5,
  671. imageUrl: this.cardInfo.avatar + '?x-oss-process=style/w375',
  672. title: this.cardInfo.nickName + ' - 电子名片',
  673. summary: this.cardInfo.title + ' ' + this.cardInfo.position.name + ' ' + this.cardInfo.message,
  674. miniProgram: {
  675. id: originalId,
  676. path: '/share/card/index?cardId=' + this.cardInfo.id,
  677. type: req.env[req.env.NODE_ENV].typeMiniProgram,
  678. webUrl: 'http://www.zhiqiyun.com'
  679. },
  680. success: ret => {
  681. console.log(JSON.stringify(ret));
  682. }
  683. });
  684. }
  685. }
  686. };
  687. </script>
  688. <style>
  689. @import './index.css';
  690. </style>