changeCounter.vue 7.63 KB
Newer Older
1 2
<template>
  <div class="container">
3 4
    <van-loading size="80px"  color="#1989fa" class="ld" v-if="overlayShow">正在处理...</van-loading>
    <van-overlay :show="overlayShow" />
xd's avatar
xd committed
5 6
    <van-radio-group v-model="radio" class="nobr"  @change="handleStoreChange">
      <van-cell-group >
xd's avatar
xd committed
7
        <van-cell   v-for="(item,index) in list" :key="index"   >
xd's avatar
xd committed
8 9
          <div class="list">
            <div class="left">
xd's avatar
xd committed
10
              <img :src="item.logo" alt="" />
xd's avatar
xd committed
11 12
            </div>
            <div class="right">
xd's avatar
xd committed
13 14
              <h3>{{ item.name }}</h3>
              <p>{{ item.summaryTitle }}</p>
xd's avatar
xd committed
15 16
            </div>
          </div>
xd's avatar
xd committed
17
          <van-radio slot="right-icon" :name="item.oyStallCode" />
xd's avatar
xd committed
18 19 20
        </van-cell>
      </van-cell-group>
    </van-radio-group>
21 22 23 24
  </div>
</template>

<script>
25 26
import { getStoreList,getMemberListByCode } from "@/api/sidebar/voucher"
import axios from "axios";
xd's avatar
xd committed
27
import { log } from 'util';
xd's avatar
xd committed
28 29 30
export default {
  data() {
    return {
xd's avatar
xd committed
31
      radio: '',
xd's avatar
xd committed
32
      userId: '',
33 34 35
      list: [],
      overlayShow: false,
      oyStallCode: ''
xd's avatar
xd committed
36 37
    }
  },
xd's avatar
xd committed
38
  created() {  
39
    if(this.$route.query.userId !== '') {
xd's avatar
xd committed
40
        this.userId = this.$route.query.userId
xd's avatar
xd committed
41
      }else {
xd's avatar
xd committed
42
        this.userId = sessionStorage.getItem('userId')
43 44 45 46 47 48 49 50
      }
    this.radio = sessionStorage.getItem('oyStallCode')
    // this.radio = 111
    this.getList()  
    // this.userId = '10000190'
  },
  methods: {
    getList() {               
xd's avatar
xd committed
51 52 53
      let params = {
        user_id: this.userId
      }
xd's avatar
xd committed
54
      getStoreList(params).then(res => {
xd's avatar
xd committed
55 56
        console.log(res.data)    
        this.list = res.data        
xd's avatar
xd committed
57 58
      })
    },
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195
    ///
    // 获取店铺的所有店员
    getAllNewFans(oyStallCode) {
      let params = {
        oyStallCode: oyStallCode
      }
        getMemberListByCode(params).then(res => {          
          this.getAllInfo(res.data)
        }).catch(err => {
          console.log(err);          
        })      
    },
     // 获取个人粉丝
    getFans() {
      let headerData = {
        agentId: "1000033",
        corpId: "ww4df265003b43fa0d"
      }
      return new Promise((resolve, reject) => {
        axios({
          url:
            "http://139.155.48.151:8085/workWx/auth/contact/listExternalContacts?userId=" + this.userId,
            method: "get",
            headers: headerData
           })
          .then(res => {            
            if(res.data.data != null) {
              sessionStorage.setItem("personalFan", res.data.data.length)
              resolve(res.data.data.length)
            }else {
              console.log('zheli');              
              if(res.errorCode == "84061") {
                sessionStorage.setItem("personalFan", 0)
                resolve(0)
              }else {
                sessionStorage.setItem("personalFan", '')
                resolve('')
              }
              
            }         
          })
          .catch(err => {
            reject(err)
          })
      })
      
    },
    // 获取店铺所有粉丝
    getAllFans() {
      let headerData = {
        agentId: "1000033",
        corpId: "ww4df265003b43fa0d"
      }    
      return new Promise((resolve, reject) => {
        axios({
          url: "http://139.155.48.151:8085/workWx/auth/contact/getCustomerInfoByOyStallCode?oyStallCode=" + this.oyStallCode,
          method: "get",
          headers: headerData
        })
        .then(res => {          
          let newList = []
          res.data.data.forEach(item => {
            if(item != null) {
              newList.push(item)
            }
          })
          sessionStorage.setItem("allFans", newList.length)
          resolve(newList.length)
        })
        .catch(err => {
          reject(err)
        })
      })
      
    },   
    getAddFans(flag, userId) {
      let JsonStr = {}
      if (flag == 1) {
        JsonStr.userid = [userId];
      } else {                  
        JsonStr.userid = userId
      }
      let timeNow = Math.round(new Date() / 1000);
      JsonStr.start_time = timeNow - 24 * 60 * 60;
      JsonStr.end_time = timeNow;
      return new Promise((resolve, reject) => {
        axios({
        url:
          "http://139.155.48.151:8085/workWx/auth/contact/getUserBehaviorData",
        method: "post",
        headers: {
          "Content-Type": "application/json",
          agentId: "1000033",
          corpId: "ww4df265003b43fa0d"
        },
        data: JsonStr
      }).then(res => {
          let data = JSON.parse(res.data.data);
          if (flag == 1) {
            // 获取个人新增粉丝
            console.log(data,'个人新增粉丝')
            if(data != null) {
              let newFans = data.behavior_data[0].new_contact_cnt + data.behavior_data[1].new_contact_cnt;
              sessionStorage.setItem("newFans", newFans)
              resolve(newFans)
            }else {
              sessionStorage.setItem("newFans", '')
              resolve('')
            }                       
          } else {
            console.log(data,'全部新增粉丝');   
            if(data != null) {
              let allNewFans = data.behavior_data[0].new_contact_cnt + data.behavior_data[1].new_contact_cnt;
              sessionStorage.setItem("allNewFans", allNewFans);
              resolve(allNewFans)
            }else {
              sessionStorage.setItem("allNewFans", '')
              resolve('')
            }                 
          }
        })
        .catch(err => {
          reject(err)
        })
      })
      
    },
    getAllInfo(list) {
      console.log('getAllInfo');     
      Promise.all([this.getFans(), this.getAllFans(),this.getAddFans(1,this.userId),this.getAddFans(2,list)]).then(res => {
        console.log('进来了');        
        console.log(res,'promise修改');
        this.overlayShow = false  
        this.$toast("切换成功")
      })
    },
    ///
xd's avatar
xd committed
196
    handleStoreChange(val) {
197 198 199
      this.overlayShow = true
      console.log(val,'修改后的oyStallCode')   
      this.oyStallCode = val  
xd's avatar
xd committed
200 201 202
      sessionStorage.setItem('oyStallCode',val)    
        let obj = this.list.find(function (obj) {
          return obj.oyStallCode == val
203
        })   
xd's avatar
xd committed
204
        sessionStorage.setItem("barName", obj.name)
205
        this.getAllNewFans(val)
xd's avatar
xd committed
206
      }
xd's avatar
xd committed
207
  }
xd's avatar
xd committed
208
}
209 210 211
</script>

<style scoped>
212 213 214 215 216 217 218 219 220 221
.ld >>> .van-loading__text {
  color: #fff;
}
.ld {
  z-index: 1000;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%,-50%);  
}
222
.container {
xd's avatar
xd committed
223 224 225 226 227 228
  height: auto;
  background-color: #fff;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
229 230 231 232 233 234 235 236 237 238 239 240 241 242
}
.title {
  height: 44px;
  background: rgba(248, 248, 248, 1);
  line-height: 44px;
  padding: 0 16px;
  font-size: 12px;
  color: rgba(45, 71, 106, 1);
}
.fg {
  padding: 0 16px;
  font-size: 12px;
  color: rgba(45, 71, 106, 1);
  height: 44px;
xd's avatar
xd committed
243
  line-height: 44px;
244 245 246 247 248 249 250
}
.icon {
  font-weight: 800;
}
.active {
  background-color: #fff;
  padding: 12px 12px 0 12px;
xd's avatar
xd committed
251
  box-shadow: 0px 2px 4px 0px rgba(221, 221, 221, 1);
252 253 254 255 256 257 258
}
.list {
  height: 94px;
  width: 100%;
  background-color: #fff;
  display: flex;
  justify-content: space-between;
xd's avatar
xd committed
259
  border-bottom: 1px solid rgba(238, 238, 238, 1);
260 261 262 263 264 265
  margin-bottom: 14px;
}
.list3 {
  border-bottom: none;
  margin-bottom: 0;
}
xd's avatar
xd committed
266 267
.left,
.right {
268 269 270
  height: 80px;
}
.left {
xd's avatar
xd committed
271 272
  width: 80px;
  background: rgba(248, 248, 248, 1);
273 274
}
.left img {
xd's avatar
xd committed
275
  width: 100%;
xd's avatar
xd committed
276
  height: 80px;
277 278 279 280 281 282 283 284
}
.right {
  width: 76%;
  padding: 10px;
  background-color: #fff;
}
h3 {
  font-size: 14px;
xd's avatar
xd committed
285 286
  font-weight: bold;
  color: rgba(45, 71, 106, 1);
287 288 289
}
p {
  margin-top: 10px;
xd's avatar
xd committed
290 291
  font-size: 12px;
  color: rgba(45, 71, 106, 0.8);
292
}
xd's avatar
xd committed
293 294 295 296 297 298
.nobr >>> [class*=van-hairline]::after {
  display: none;
}
.nobr >>> .van-cell:not(:last-child)::after {
  display: none;
}
299
</style>