123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
- import {
- ApiModel
- } from "../../utils/api";
- const _Http = new ApiModel;
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- checked: true, //开关
- partnerDetails: {}, //合作详情
- seIndex: null, //合作方式
- throttle: true, //截流
- fisadministrator: null,
- isCancel: false, //是否取消合作
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- const data = JSON.parse(options.data)
- this.setData({
- partnerDetails: data,
- seIndex: data.ftype,
- fisadministrator: (wx.getStorageSync('userData').fisadministrator == 1) ? false : true,
- })
- },
- /* 开关 */
- onChange({
- detail
- }) {
- const that = this;
- if (this.data.fisadministrator) return wx.showToast({
- title: '当前账号无权限操作',
- icon: "none"
- });
- if (this.data.checked) {
- wx.showModal({
- title: "提示",
- content: '是否确定取消与“' + this.data.partnerDetails.fbrand + '”的合作关系',
- success: function (res) {
- if (res.confirm) {
- that.setData({
- checked: detail,
- isCancel: true
- });
- }
- }
- })
- } else {
- that.setData({
- checked: detail,
- isCancel: false
- });
- }
- },
- /* 预览合作商logo */
- previewImg() {
- const urls = [this.data.partnerDetails.attinfos[0].fobsurl]
- wx.previewImage({
- current: 1, // 当前显示图片的http链接
- urls: urls
- })
- },
- /* 提交 */
- submit() {
- /* 截流 */
- if (!this.data.throttle) return;
- this.setData({
- throttle: false
- });
- /* 取消合作 */
- if (this.data.isCancel) return _Http.basic({
- "accesstoken": wx.getStorageSync('userData').token,
- "classname": "customer.tagents.tagents",
- "method": "delete_cooperation",
- "content": {
- "tcooperationagentsid": this.data.partnerDetails.tcooperationagentsid
- }
- }).then(res => {
- if (res.msg != '成功') return wx.showToast({
- title: res.data,
- icon: "error"
- })
- setTimeout(() => {
- wx.navigateBack({
- delta: 1,
- })
- }, 500);
- })
- /* 发送修改请求 */
- if (this.data.seIndex != this.data.partnerDetails.ftype) {
- _Http.basic({
- "accesstoken": wx.getStorageSync('userData').token,
- "classname": "customer.tagents.tagents",
- "method": "update_cooperation",
- "content": {
- "tcooperationagentsid": this.data.partnerDetails.tcooperationagentsid,
- "ftype": this.data.seIndex
- }
- }).then(res => {
- if (res.msg != '成功') return wx.showToast({
- title: res.data,
- icon: "none"
- });
- wx.showToast({
- title: '修改成功'
- });
- setTimeout(() => {
- wx.navigateBack({
- delta: 1,
- })
- }, 500);
- });
- } else {
- wx.showToast({
- title: '保存成功'
- });
- setTimeout(() => {
- wx.navigateBack({
- delta: 1,
- })
- }, 500);
- }
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|