The WeChat applet hides the customer service button and can be closed at any time by replacing & adding a reminder card with a picture.

clipboard.png

As shown in the figure, the customer service button and the blue gradient prompt card in the lower right corner of this case can be closed at any time.

WeChat official gave the customer service button label
<contact-button type="default-dark" size="100"></contact-button>

The style of this label cannot be modified. If we want to change the picture we want to change, what do we need to do? Just like the style on my picture.
My customer service control is placed in a central position in a perfect view, so I first position to the center position by position, and maximize the size.

Then set the transparency to 0, and then set a picture background for the perfect circle view, the picture is the icon you want to display

Cue card

The prompt card is a view, there is a × in the view to bind the hidden event, bindtap = "onChangeShowState" is used to hide the view

index.wxml

<!-- 提示卡片 -->
<view class="bright789_view_hide{{showView?'bright789_view_show':''}}">
  <view class="bright789-text">
      <view bindtap="onChangeShowState" class="close">×</view>
      <view class="text">有疑问可以点这里咨询哦</view>
  </view>
</view>
<!-- 悬浮按钮 -->
<view class="zixun"><contact-button type="default-dark" size="100" class="kf"></contact-button></view>

index.wxss

.zixun{
  width: 55px;
  height: 55px;
  background: url(http://wxpad.cn/yunpan/cdn/imgsrc/1530949769.png)no-repeat;
  position: fixed;
  bottom: 35px;
  right: 35px;
  border-radius: 50%;
  box-shadow: 0 0 5px #ddd;
  text-align: center;
  font-size: 14px;
  color: #333;
}

.zixun .kf{
  position: relative;
  top: 0px;
  left: 0px;
  margin:15px auto;
  opacity: 0;
}

.bright789-text{
  position: fixed;
  bottom: 100px;
  right: 65px;
  width: 200px;
  height: 45px;
  background-image: linear-gradient(to left, #4481eb 0%, #04befe 100%);
  border-bottom-left-radius: 50px;
  border-top-left-radius: 50px;
  border-top-right-radius: 50px;
  z-index: 99999999;
  box-shadow: 0 0 10px #eee;
  line-height: 40px;
  text-indent: 15px;
}

.bright789-text .close{
  font-size: 1.5em;
  color: #fff;
}


.bright789-text .text{
  font-size: 13px;
  color: #fff;
  margin-top: -38px;
  margin-left: 20px;
}

.bright789_view_hide{
    display: none;
}

index.js

//index.js
//获取应用实例
const app = getApp()
Page({
  data: {
    showView: true
  },

onLoad: function (options) {
  // 生命周期函数--监听页面加载
  showView: (options.showView == "true" ? true : false)
},
onChangeShowState: function () {
  var that = this;
  that.setData({
    showView: (!that.data.showView)
  })
 }
})

OK, the production is complete!

clipboard.png

Author: TANKING

Guess you like

Origin www.cnblogs.com/jlfw/p/12707523.html