猎豆优选小程序

zskf.vue 7.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <template>
  2. <view>
  3. <!-- 顶部导航 -->
  4. <u-navbar class="navbar-wrap" :is-back="true" title="专属客服" :background="background" title-color="#ffffff" back-icon-color="#ffffff" />
  5. <view class="kf-block">
  6. <image class="avatar" v-if="serviceInfo.headimgurl" :src="serviceInfo.headimgurl" />
  7. <image class="avatar" v-else src="https://ld.726p.com/ldyx_static/imgs/avatar-login.png" />
  8. <text>我是你的专属客服,添加微信好友可:</text>
  9. </view>
  10. <block v-if="serviceInfo.text">
  11. <view class="text-block" v-for="item in serviceInfo.text">
  12. <image class="img" src="https://ld.726p.com/ldyx_static/imgs/kefu_icon.png" mode="widthFix"></image>
  13. <text>{{item}}</text>
  14. </view>
  15. </block>
  16. <image class="kf-evm" :src="serviceInfo.qrcode" mode="widthFix" :show-menu-by-longpress="true"></image>
  17. <!-- #ifdef H5 -->
  18. <view class="h5-hint">长按识别二维码或保存二维码到手机</view>
  19. <view class="h5-hint">您还可以复制微信号添加专属客服</view>
  20. <!-- #endif -->
  21. <!-- #ifdef MP-WEIXIN -->
  22. <view class="button" @click="downloadImg">保存二维码到手机</view>
  23. <!-- #endif -->
  24. <block v-if="serviceInfo.wechat">
  25. <view class="button" @click="copyEvent">复制微信号</view>
  26. <!-- <view class="wx-text">微信号:{{serviceInfo.wechat}}</view> -->
  27. </block>
  28. <!-- #ifdef MP-WEIXIN -->
  29. <view class="wx-text">长按识别上方二维码,添加客服</view>
  30. <!-- #endif -->
  31. <view class="add-question">
  32. 添加客服遇到问题,请联系<text class="fws_button" @click="showMask = true">服务商</text>
  33. </view>
  34. <!-- 服务商弹窗 -->
  35. <u-mask :show="showMask" @click="showMask = false">
  36. <view class="warp">
  37. <view class="rect" @tap.stop>
  38. <view class="kf-block">
  39. <image class="avatar" v-if="serviceInfo.server_info.headimgurl" :src="serviceInfo.server_info.headimgurl" />
  40. <image class="avatar" v-else src="https://ld.726p.com/ldyx_static/imgs/avatar-login.png" />
  41. <text>我是服务商</text>
  42. </view>
  43. <image class="kf-evm" :src="serviceInfo.server_info.qrcode" mode="widthFix" :show-menu-by-longpress="true"></image>
  44. <!-- #ifdef H5 -->
  45. <view class="h5-hint">长按识别二维码或保存二维码到手机</view>
  46. <view class="h5-hint">您还可以复制微信号添加专属客服</view>
  47. <!-- #endif -->
  48. <!-- #ifdef MP-WEIXIN -->
  49. <view class="button" @click="downloadImg('fws')">保存二维码到手机</view>
  50. <!-- #endif -->
  51. <block v-if="serviceInfo.server_info.wechat">
  52. <view class="button" @click="copyEvent('fws')">复制微信号</view>
  53. <!-- <view class="wx-text">微信号:{{serviceInfo.server_info.wechat}}</view> -->
  54. </block>
  55. <!-- #ifdef MP-WEIXIN -->
  56. <view class="wx-text">长按识别上方二维码,添加客服</view>
  57. <!-- #endif -->
  58. </view>
  59. </view>
  60. </u-mask>
  61. </view>
  62. </template>
  63. <script>
  64. const app = getApp()
  65. export default {
  66. data() {
  67. return {
  68. background: app.globalData.navbarBackground,
  69. serviceInfo: {}, // 客服信息
  70. showMask: false, // 服务商弹框
  71. }
  72. },
  73. onLoad() {
  74. this.getService()
  75. },
  76. methods: {
  77. // 点击下载图片事件,h5不适用
  78. downloadImg(type) {
  79. wx.showLoading({
  80. title: '加载中...'
  81. });
  82. let url = this.serviceInfo.qrcode;
  83. if(type == 'fws'){ // 服务商
  84. url = this.serviceInfo.server_info.qrcode;
  85. }
  86. wx.downloadFile({
  87. url: url, //图片地址
  88. success: function (res) {
  89. //wx.saveImageToPhotosAlbum方法:保存图片到系统相册
  90. wx.saveImageToPhotosAlbum({
  91. filePath: res.tempFilePath, //图片文件路径
  92. success: function (data) {
  93. wx.hideLoading(); //隐藏 loading 提示框
  94. wx.showModal({
  95. title: '提示',
  96. content: '保存成功',
  97. modalType: false,
  98. })
  99. },
  100. // 接口调用失败的回调函数
  101. fail: function (err) {
  102. if (err.errMsg === "saveImageToPhotosAlbum:fail:auth denied" || err.errMsg === "saveImageToPhotosAlbum:fail auth deny" || err.errMsg === "saveImageToPhotosAlbum:fail authorize no response") {
  103. wx.showModal({
  104. title: '提示',
  105. content: '需要您授权保存相册',
  106. modalType: false,
  107. success: modalSuccess => {
  108. wx.openSetting({
  109. success(settingdata) {
  110. if (settingdata.authSetting['scope.writePhotosAlbum']) {
  111. wx.showModal({
  112. title: '提示',
  113. content: '获取权限成功,再次点击图片即可保存',
  114. modalType: false,
  115. })
  116. } else {
  117. wx.showModal({
  118. title: '提示',
  119. content: '获取权限失败,将无法保存到相册哦~',
  120. modalType: false,
  121. })
  122. }
  123. },
  124. fail(failData) {
  125. console.log("failData", failData)
  126. },
  127. complete(finishData) {
  128. console.log("finishData", finishData)
  129. }
  130. })
  131. }
  132. })
  133. }
  134. },
  135. complete(res) {
  136. wx.hideLoading(); //隐藏 loading 提示框
  137. }
  138. })
  139. }
  140. })
  141. },
  142. // 获取客服信息
  143. async getService () {
  144. try {
  145. const url = this.$api.adzoneCreate_belongToYou;
  146. const params = {}
  147. uni.showLoading({ title: '加载中...', mask: true })
  148. const { data: res } = await this.$postJSON(url, params)
  149. if (res && res.errno == 0) {
  150. this.serviceInfo = res.rst;
  151. } else {
  152. uni.showToast({ title: res.err || '操作失败', icon: 'none' })
  153. }
  154. } catch (error) {
  155. uni.showToast({ title: '服务器错误', icon: 'none' })
  156. } finally {
  157. uni.hideLoading()
  158. }
  159. },
  160. //复制微信号
  161. copyEvent(type){
  162. let text = this.serviceInfo.wechat;
  163. if(type == 'fws'){ // 服务商
  164. text = this.serviceInfo.server_info.wechat;
  165. }
  166. this.$copyEvent({text})
  167. },
  168. }
  169. }
  170. </script>
  171. <style scoped lang="scss">
  172. .kf-block{
  173. display: flex;
  174. justify-content: center;
  175. align-items: center;
  176. margin-top: 40rpx;
  177. line-height: 50rpx;
  178. font-size: 32rpx;
  179. color: #333333;
  180. .avatar{
  181. width: 70rpx;
  182. height: 70rpx;
  183. border-radius: 50%;
  184. margin-right: 20rpx;
  185. }
  186. }
  187. .text-block{
  188. display: flex;
  189. justify-content: center;
  190. align-items: center;
  191. font-size: 32rpx;
  192. line-height: 40rpx;
  193. margin-top: 20rpx;
  194. .img{
  195. width: 40rpx;
  196. height: 40rpx;
  197. margin-right: 10rpx;
  198. }
  199. }
  200. .kf-evm{
  201. display: block;
  202. width: 280rpx;
  203. height: 280rpx;
  204. margin: 80rpx auto;
  205. }
  206. .button{
  207. width: 440rpx;
  208. line-height: 70rpx;
  209. background-color: #F52B18;
  210. font-size: 32rpx;
  211. color: #FFFFFF;
  212. text-align: center;
  213. margin: auto;
  214. margin-top: 30rpx;
  215. border-radius: 6rpx;
  216. }
  217. .wx-text{
  218. font-size: 26rpx;
  219. text-align: center;
  220. line-height: 40rpx;
  221. margin-top: 10rpx;
  222. }
  223. .add-question{
  224. text-align: center;
  225. font-size: 26rpx;
  226. line-height: 40rpx;
  227. margin-top: 100rpx;
  228. .fws_button{
  229. color: #F52B18;
  230. margin-left: 6rpx;
  231. font-size: 32rpx;
  232. font-weight: bold;
  233. }
  234. }
  235. .h5-hint{
  236. text-align: center;
  237. font-size: 26rpx;
  238. line-height: 40rpx;
  239. color:#666;
  240. }
  241. .warp {
  242. display: flex;
  243. align-items: center;
  244. justify-content: center;
  245. height: 100%;
  246. }
  247. .rect {
  248. width: 600rpx;
  249. height: 900rpx;
  250. background-color: #fff;
  251. border-radius: 20rpx;
  252. padding: 20rpx 40rpx;
  253. }
  254. </style>