微信分享
$().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
}
複製程式碼