微信分享、vue中select的v-model绑定(监听enter键)、数组对象重组(18/06/22)

微信分享

 $().ready(function () {
            var title = '标题';
            var desc = '描述:随便输入吧,哈哈哈哈哈哈哈哈哈哈哈。';
            var link = location.href.split('#')[0];
            var imgUrl = 'http://XXXX/img/course/wxshare-mc.png';//自己放线上图片

            $.ajax({
                url: "/wechat/shareconfig/",
                type: "POST",
                cache: false,
                dataType: "json",
                data: { url: link },
                success: function (data) {
                    wx.config(data);
                    wx.ready(function () {

                        // 2. 分享接口
                        // 2.1 监听“分享给朋友”,按钮点击、自定义分享内容及分享结果接口

                        wx.onMenuShareAppMessage({
                            title: title,
                            desc: desc,
                            link: link,
                            imgUrl: imgUrl,
                            trigger: function (res) {

                            },
                            success: function (res) {
                                window.location.href = "https://juejin.im/user/5b109822e51d45069352ad44";
                            },
                            cancel: function (res) {

                            },
                            fail: function (res) {

                            }
                        });



                        // 2.2 监听“分享到朋友圈”按钮点击、自定义分享内容及分享结果接口

                        wx.onMenuShareTimeline({
                            title: title,
                            link: link,
                            imgUrl: imgUrl,
                            trigger: function (res) {

                            },
                            success: function (res) {
                                window.location.href = "https://juejin.im/user/5b109822e51d45069352ad44";
                            },
                            cancel: function (res) {

                            },
                            fail: function (res) {

                            }
                        });

                        //获取“分享到QQ”按钮点击状态及自定义分享内容接口
                        wx.onMenuShareQQ({
                            title: title, // 分享标题
                            desc: desc, // 分享描述
                            link: link, // 分享链接
                            imgUrl: imgUrl, // 分享图标
                            success: function () {
                                // 用户确认分享后执行的回调函数
                            },
                            cancel: function () {
                                // 用户取消分享后执行的回调函数
                            }
                        });



                    });
                },
                error: function (data) {


                }
            });
        });
复制代码

vue中监听enter事件并且保存select的v-model

 contactSearch(e) {
      const name = this.$refs.input.$el.querySelector("input").value.trim();
      if (name !== "") {
        this.load.contact = true;
        contactApi.getContactList({ name: name }).subscribe(
          data => {
            this.load.contact = false;
            this.contactList = data.contacts;
            console.log(this.contactList);
            for (var i = 0; i < this.contactList.length; i++) {
              console.log(this.newContactList)
              this.newContactList[i]=[];
              this.newContactList[i].companyNamePeople= this.contactList[i].name + "(" +this.contactList[i].company.name +")";
              this.newContactList[i].id=this.contactList[i].id 
            }
            this.member.contactId = name;
          },
          err => {
            this.load.contact = false;
            this.contactList = [];
          }
        );
      } else {
        // this.fetchContactList()
      }
    },
复制代码

遍历对象数组并取出字段组合成新数组

在data中初始化数组

 data() {
    return {
         contactList: [],
        newContactList: []
    }
  }

复制代码

接下来对获取的data.contacts进行处理

 this.contactList = data.contacts;
            console.log(this.contactList);
            for (var i = 0; i < this.contactList.length; i++) {
              console.log(this.newContactList)
              this.newContactList[i]=[];
              this.newContactList[i].companyNamePeople= this.contactList[i].name + "(" +this.contactList[i].company.name +")";
              this.newContactList[i].id=this.contactList[i].id 
    }
复制代码
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值