kefu.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. <template>
  2. <view style="height: 100vh;">
  3. <!-- border-radius: 32upx; -->
  4. <view style="text-align: center;background: #FFFFFF;padding: 30upx;">
  5. <view class="item">
  6. <view class="lef">
  7. <image v-if="globalImages" :src="globalImages + 'images/static/my/QQ.png'"></image>
  8. <view class="txt">
  9. <text>QQ</text>
  10. <text>{{qq}}</text>
  11. </view>
  12. </view>
  13. <view @click="copyHref" class="copy" data-txt='qq'>复制QQ</view>
  14. </view>
  15. <view class="item">
  16. <view class="lef">
  17. <image v-if="globalImages" :src="globalImages + 'images/static/my/wx.png'"></image>
  18. <view class="txt">
  19. <text>微信</text>
  20. <text>{{weixin}}</text>
  21. </view>
  22. </view>
  23. <view @click="copyHref" class="copy" data-txt='weixin'>复制微信</view>
  24. </view>
  25. <view class="item">
  26. <view class="lef">
  27. <image v-if="globalImages" :src="globalImages + 'images/static/my/phone.png'"></image>
  28. <view class="txt">
  29. <text>电话</text>
  30. <text>{{phone}}</text>
  31. </view>
  32. </view>
  33. <view @click="copyHref" data-txt='phone' class="copy">拨打电话</view>
  34. </view>
  35. <!-- #ifdef MP-WEIXIN -->
  36. <view class="item">
  37. <view class="lef">
  38. <image v-if="globalImages" :src="globalImages + 'images/static/my/kf.png'"></image>
  39. <view class="txt">
  40. <text>在线客服</text>
  41. <text>在线客服专员为你解答问题</text>
  42. </view>
  43. </view>
  44. <button class="copys" data-txt='qq' v-if="SelKeFu==2" open-type="contact">在线客服</button>
  45. <button class="copys" data-txt='qq' v-else @click="gotomath()">在线客服</button>
  46. </view>
  47. <!-- #endif -->
  48. <!-- #ifndef MP-WEIXIN -->
  49. <view class="item">
  50. <view class="lef">
  51. <image v-if="globalImages" :src="globalImages + 'images/static/my/kf.png'"></image>
  52. <view class="txt">
  53. <text>在线客服</text>
  54. <text>在线客服专员为你解答问题</text>
  55. </view>
  56. </view>
  57. <button class="copys" data-txt='qq' @click="gotomath()">在线客服</button>
  58. </view>
  59. <!-- #endif -->
  60. </view>
  61. </view>
  62. </template>
  63. <script>
  64. import { waitForGlobalImages } from '@/utils/globalImageLoader'
  65. export default {
  66. data() {
  67. return {
  68. SelKeFu: '2',
  69. image: 'https://taobao.xianmxkj.com/custom.jpg',
  70. isWeiXin: false,
  71. weixin: '',
  72. qq: '',
  73. phone: '',
  74. webviewStyles: {
  75. progress: {
  76. color: '#FF2638'
  77. }
  78. },
  79. globalImages: '',
  80. };
  81. },
  82. onLoad() {
  83. waitForGlobalImages().then((path) => {
  84. console.log('✅ 全局图片路径:', path)
  85. this.globalImages = path
  86. })
  87. this.SelKeFu = this.$queue.getData('SelKeFu');
  88. // #ifdef H5
  89. let ua = navigator.userAgent.toLowerCase();
  90. if (ua.indexOf('micromessenger') !== -1) {
  91. this.isWeiXin = true;
  92. }
  93. // #endif
  94. //微信号码
  95. this.$Request.getT('/app/common/type/44').then(res => {
  96. if (res.code == 0) {
  97. if (res.data && res.data.value) {
  98. this.weixin = res.data.value;
  99. }
  100. }
  101. });
  102. //客服电话
  103. this.$Request.getT('/app/common/type/252').then(res => {
  104. if (res.code == 0) {
  105. if (res.data && res.data.value) {
  106. this.phone = res.data.value;
  107. }
  108. }
  109. });
  110. //qq号码
  111. this.$Request.getT('/app/common/type/274').then(res => {
  112. if (res.code == 0) {
  113. if (res.data && res.data.value) {
  114. this.qq = res.data.value;
  115. }
  116. }
  117. });
  118. },
  119. onPullDownRefresh: function() {
  120. uni.stopPullDownRefresh(); // 停止刷新
  121. },
  122. methods: {
  123. //微信企业客服
  124. gotomath() {
  125. // #ifdef MP-WEIXIN
  126. let that = this
  127. try {
  128. wx.openCustomerServiceChat({
  129. extInfo: {
  130. url: that.$queue.getData('SelKeFuLink')
  131. },
  132. corpId: that.$queue.getData('SelKeFuAppId'),
  133. success(res) {},
  134. fail(res) {
  135. console.error(res)
  136. }
  137. })
  138. } catch (error) {
  139. console.error("catchcatch" + error)
  140. uni.showToast({
  141. title: '请更新至微信最新版本'
  142. });
  143. }
  144. // #endif
  145. // #ifndef MP-WEIXIN
  146. let url = this.$queue.getData('SelKeFuLink');
  147. if (url.indexOf('/pages/') !== -1 || url.indexOf('/my/') !== -1) {
  148. uni.navigateTo({
  149. url
  150. });
  151. } else {
  152. //#ifndef H5
  153. uni.navigateTo({
  154. url: '/pages/index/webView?url=' + url
  155. });
  156. //#endif
  157. //#ifdef H5
  158. window.location.href = url;
  159. //#endif
  160. }
  161. // #endif
  162. },
  163. //邀请码复制
  164. copyHref(e) {
  165. console.log(e.target.dataset.txt)
  166. if (e.target.dataset.txt == 'qq') {
  167. this.copy(this.qq)
  168. } else if (e.target.dataset.txt == 'weixin') {
  169. this.copy(this.weixin)
  170. } else {
  171. uni.makePhoneCall({
  172. phoneNumber: this.phone
  173. })
  174. }
  175. },
  176. copy(item) {
  177. uni.setClipboardData({
  178. data: item,
  179. success: r => {
  180. this.$queue.showToast('复制成功');
  181. }
  182. });
  183. },
  184. saveImg() {
  185. let that = this;
  186. uni.saveImageToPhotosAlbum({
  187. filePath: that.image,
  188. success(res) {
  189. that.$queue.showToast('保存成功');
  190. }
  191. });
  192. },
  193. rests() {
  194. uni.showToast({
  195. title: '已刷新请再次长按识别',
  196. mask: false,
  197. duration: 1500,
  198. icon: 'none'
  199. });
  200. window.location.reload();
  201. }
  202. }
  203. };
  204. </script>
  205. <style scoped>
  206. /* @import '../../static/css/index.css'; */
  207. .item {
  208. display: flex;
  209. justify-content: space-between;
  210. align-items: center;
  211. margin-bottom: 36rpx;
  212. }
  213. .items {
  214. margin-bottom: 0;
  215. }
  216. .lef {
  217. display: flex;
  218. justify-content: flex-start;
  219. align-items: center;
  220. }
  221. .item image {
  222. width: 89rpx;
  223. height: 89rpx;
  224. margin-right: 26rpx;
  225. }
  226. .item .txt {
  227. display: flex;
  228. flex-direction: column;
  229. justify-content: flex-start;
  230. align-items: flex-start;
  231. }
  232. .txt>text:nth-child(1) {
  233. font-size: 32rpx;
  234. font-family: PingFang SC;
  235. font-weight: bold;
  236. color: #1F2029;
  237. /* line-height: 87rpx; */
  238. margin-bottom: 10rpx;
  239. }
  240. .txt>text:nth-child(2) {
  241. font-size: 28rpx;
  242. font-family: PingFang SC;
  243. font-weight: 500;
  244. color: #666666;
  245. /* line-height: 87rpx; */
  246. }
  247. .copy {
  248. width: 140rpx;
  249. height: 54rpx;
  250. background: #FF1E43;
  251. border-radius: 27rpx;
  252. text-align: center;
  253. line-height: 54rpx;
  254. font-size: 24rpx;
  255. font-family: PingFang SC;
  256. font-weight: bold;
  257. color: #FFFFFF;
  258. }
  259. .copys {
  260. height: 54rpx;
  261. background: #FF1E43;
  262. border-radius: 27rpx;
  263. text-align: center;
  264. line-height: 54rpx;
  265. font-size: 24rpx;
  266. font-family: PingFang SC;
  267. font-weight: bold;
  268. color: #FFFFFF;
  269. margin-right: 0rpx;
  270. }
  271. /*
  272. <!-- <view style="font-size: 38upx;color: #000000">添加客服微信咨询</view>
  273. <view style="font-size: 32upx;margin-top: 32upx;color: #000000">微信号:{{weixin}}</view>
  274. <view @click="copyHref" style="width:200upx;margin-top: 32upx;font-size: 30upx;margin-left: 36%;color: #FFFFFF;background: #FF2638;padding: 4upx 20upx;border-radius: 24upx;">一键复制</view>
  275. <image @click="saveImg" mode="aspectFit" style="margin-top: 32upx" :src="image"></image>
  276. <view style="font-size: 28upx;color: #000000;margin-top: 32upx" v-if="isWeiXin">{{ isWeiXin ? '长按识别上方二维码' : '' }}</view>
  277. <view v-if="isWeiXin" style="font-size: 24upx;color: #000000;margin-top: 80upx" @click="rests">无法识别?</view> -->
  278. */
  279. </style>