index.vue 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <template>
  2. <view>
  3. <!-- :class="specClass" :style="'top:' + contactTop + 'px;'" -->
  4. <view :class="[className,classNames]" :style="styles" @click="customerServiceChat" v-if="type == 2">
  5. <image lazy-load="true" :src="imgUrl" :mode="imageMode" v-if="imgUrl" :style="imgStyle"></image>
  6. <view v-if="buttonText">
  7. {{buttonText}}
  8. </view>
  9. </view>
  10. <button style="font-size: inherit;color: inherit;" open-type="contact" hover-class="none" :class="className" v-else>
  11. <image lazy-load="true" :src="imgUrl" v-if="imgUrl" :style="imgStyle"></image>
  12. <view v-if="buttonText">{{buttonText}}</view>
  13. </button>
  14. </view>
  15. </template>
  16. <script>
  17. const app = getApp();
  18. const req = require("../../utils/request.js");
  19. export default {
  20. data() {
  21. return {
  22. chatPrams: {},
  23. type: 1
  24. };
  25. },
  26. components: {},
  27. props: {
  28. imgUrl: String,
  29. buttonText: String,
  30. className: String,
  31. classNames: String,
  32. styles: String,
  33. imageMode: String,
  34. isUpdate: {
  35. type: Boolean,
  36. default: true
  37. },
  38. productType: {
  39. type: Number,
  40. default: 0
  41. },
  42. imgStyle: String
  43. },
  44. watch: {},
  45. mounted() {
  46. // console.log('ready');
  47. this.getChatPrams();
  48. // this.getChatList();
  49. },
  50. methods: {
  51. getChatPrams() {
  52. let that = this;
  53. let chatPrams = req.getStorage('chatService');
  54. if(chatPrams){
  55. that.chatPrams = chatPrams;
  56. that.type = chatPrams.type;
  57. console.log('type==', that.type)
  58. that.$forceUpdate();
  59. }
  60. },
  61. customerServiceChat() {
  62. let chatPrams = this.chatPrams;
  63. wx.openCustomerServiceChat({
  64. extInfo: {
  65. url: chatPrams.url
  66. },
  67. corpId: chatPrams.enterpriseId,
  68. success(res) {
  69. console.log('调用微信客服')
  70. }
  71. })
  72. },
  73. }
  74. };
  75. </script>
  76. <style>
  77. @import "./index.css";
  78. </style>