teacherDet.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <template>
  2. <view v-if="detaile">
  3. <!-- <view class="info ddflex">
  4. <image :src="detaile.headUrl" mode="aspectFill"></image>
  5. <view class="fflex">
  6. <view class="tit">{{detaile.realName}}</view>
  7. <view class="rec-tag ddflex" v-if="detaile.userExtend && detaile.userExtend.label">
  8. <text class="ddflex" v-for="(it,idx) in detaile.userExtend.label.split(',')" :key="idx">{{it}}</text>
  9. </view>
  10. <view class="tea-bri" v-if="detaile.userExtend && detaile.userExtend.projects">{{detaile.userExtend.projects}}</view>
  11. </view>
  12. </view>
  13. <view class="content">
  14. <view class="viewMore">
  15. <mp-html :content="detaile.userExtend.brief" :lazy-load="true" @imgtap="choose"></mp-html>
  16. </view>
  17. </view> -->
  18. <image :src="detaile.headUrl" mode="aspectFill" class="zj-bg"></image>
  19. <view class="content-box">
  20. <view class="zj-name ddflex">
  21. <text class="fflex">{{detaile.realName}}</text>
  22. <image @click="showPop" class="qr" src="../static/images/qrcode.png" v-if="detaile.wechatQrcode"></image>
  23. </view>
  24. <view class="zj-label">{{detaile.userExtend.label}}</view>
  25. <view class="title" v-if="detaile.userExtend.brief">专家简介</view>
  26. <view class="zj-brief" v-if="detaile.userExtend.brief">
  27. <mp-html :content="detaile.userExtend.brief" :lazy-load="true" @imgtap="choose"></mp-html>
  28. </view>
  29. <view class="title" v-if="detaile.userExtend.projects">擅长项目</view>
  30. <view class="zj-brief" v-if="detaile.userExtend.projects">
  31. <mp-html :content="detaile.userExtend.projects" :lazy-load="true" @imgtap="choose"></mp-html>
  32. </view>
  33. </view>
  34. <view class="ceng" v-if="isShowPop" @click="hidePop"></view>
  35. <view class="popup" :style="'bottom:' + sBottom +';'">
  36. <image src="../static/images/cancel.png" class="cancel" @click="hidePop()"></image>
  37. <image :src="detaile.wechatQrcode" class="code" show-menu-by-longpress="true"></image>
  38. <view class="tip">请{{detaile.wechatNumber ? '复制微信号或' : ''}}长按识别或保存二维码去微信添加</view>
  39. <view class="pop-btn dflex">
  40. <view @click="copy(detaile.wechatNumber)" v-if="detaile.wechatNumber">复制微信号</view>
  41. <view @click="saveImg()">保存二维码</view>
  42. </view>
  43. <!-- <image src="../../static/images/close.png" class="close" @click="hidePop"></image> -->
  44. </view>
  45. <!-- #ifdef H5 -->
  46. <wx-share ref="wxshare" />
  47. <!-- #endif -->
  48. </view>
  49. </template>
  50. <script>
  51. const app = getApp();
  52. const req = require('../../utils/request.js');
  53. const api = require('../../utils/api.js');
  54. const util = require('../../utils/util.js');
  55. import mpHtml from "../../components/mp-html/components/mp-html/mp-html";
  56. export default {
  57. components: {
  58. mpHtml,
  59. },
  60. data() {
  61. return {
  62. detaile: '',
  63. viewMore: false,
  64. config: {},
  65. isShowPop: false,
  66. sBottom: '-100%'
  67. };
  68. },
  69. onLoad: async function(options) {
  70. if(options.appId) req.setStorage('appId',options.appId);
  71. uni.showShareMenu({
  72. withShareTicket: true,
  73. menus: ['shareAppMessage', 'shareTimeline']
  74. });
  75. this.id = options.id;
  76. await this.getDetail();
  77. // await this.monitor();
  78. },
  79. onShow(){
  80. this.config = JSON.parse(req.getStorage('configRes'))
  81. // this.getBrowse();
  82. },
  83. onShareAppMessage: function() {
  84. return this.onShareMessage();
  85. },
  86. onShareTimeline() {
  87. return {
  88. title: this.detail.realName,
  89. image: this.detaile.headUrl,
  90. query: '/topic/teacherDet/teacherDet?id=' + this.detaile.id
  91. };
  92. },
  93. onReady() {
  94. // #ifdef H5
  95. var that = this;
  96. //初始化分享内容
  97. setTimeout(function() {
  98. var shareContent = that.onShareMessage();
  99. if (shareContent) {
  100. shareContent.path = window.location.origin + shareContent.path;
  101. }
  102. console.log('分享内容》》》》》', shareContent);
  103. that.$refs.wxshare.init(shareContent);
  104. }, 4 * 1000);
  105. // #endif
  106. },
  107. methods: {
  108. onShareMessage(){
  109. let path = '';
  110. let isSolution = '';
  111. // #ifndef H5
  112. isSolution = req.env[req.env.NODE_ENV].isSolution;
  113. // #endif
  114. // #ifdef H5
  115. isSolution = false;
  116. // #endif
  117. let userInfo = req.getStorage('userInfo');
  118. if(isSolution){
  119. path = '/share/home/index?appId='+req.getStorage('appId')+'&userId='+userInfo.id;
  120. }else{
  121. path = '/topic/teacherDet/teacherDet?id=' + this.detaile.id + '&appId=' + req.getStorage('appId');
  122. }
  123. return {
  124. title: this.detaile.realName,
  125. imageUrl:this.detaile.headUrl,
  126. path: path
  127. };
  128. },
  129. showPop(){
  130. this.isShowPop = true;
  131. this.sBottom = 0;
  132. },
  133. hidePop(){
  134. this.isShowPop = false;
  135. this.sBottom = '-100%';
  136. },
  137. copy(content){
  138. uni.setClipboardData({
  139. //准备复制的数据
  140. data: content,
  141. success: function (res) {
  142. req.msg('复制成功')
  143. }
  144. })
  145. },
  146. saveImg() {
  147. let that = this;
  148. let codeUrl = this.detaile.wechatQrcode;
  149. uni.saveImageToPhotosAlbum({
  150. filePath: codeUrl,
  151. success(res) {
  152. uni.showToast({
  153. title: '图片保存成功',
  154. icon: 'none',
  155. success() {
  156. },
  157. fail() {
  158. uni.showToast({
  159. title: '图片保存失败'
  160. });
  161. }
  162. })
  163. }
  164. })
  165. },
  166. choose: function () {
  167. let freshen = false;
  168. this.$emit('freshen', {
  169. detail: freshen
  170. });
  171. },
  172. getDateTimeStamp(dateStr){
  173. return util.getDateDiff(Date.parse(dateStr.replace(/-/gi,"/")));
  174. },
  175. splitLabel(label){
  176. if(!label){
  177. return false;
  178. }else{
  179. if (label.indexOf(",") > 0){
  180. return label.split(',');
  181. }else{
  182. return label.split(',');
  183. }
  184. }
  185. },
  186. getDetail() {
  187. let that = this;
  188. let apiUrl = '/api/v3/sysUser/info';
  189. return new Promise((resolve,reject)=>{
  190. req.getRequest(apiUrl,{ id: that.id },async res => {
  191. that.detaile = res;
  192. resolve();
  193. },true);
  194. })
  195. },
  196. getBrowse(){
  197. let params={
  198. bindId: this.id,
  199. type: 2
  200. }
  201. req.postRequest('/api/browse', params, data => {});
  202. },
  203. }
  204. };
  205. </script>
  206. <style>
  207. @import "./teacherDet.css";
  208. </style>