gift.vue 8.66 KB
Newer Older
1 2
<template>
  <view class="gift">
3
    <view class="gift-remark">{{ $lang.lang.integral.pointsRemark }}</view>
4 5
    <view class="gift-select">
      <view class="select-list">
6 7
        <view class="list-item" v-for="(item, index) in netList" :key="index"
          >{{ item }}
chenwei's avatar
chenwei committed
8
          <uni-icons class="list-icon" type="right" color="#B3B3B3" size="12"></uni-icons>
9 10 11
        </view>
      </view>
      <view class="select-right">
12 13 14 15 16 17 18 19
        <picker
          mode="multiSelector"
          :range="pickerData"
          :value="pickerValue"
          :range-key="locale === 'zh' ? 'labelZh' : 'labelEn'"
          @change="bindPickerChange"
          @columnchange="bindColumnChange"
        >
20
          {{ $lang.lang.integral.outlets }}
chenwei's avatar
chenwei committed
21
          <uni-icons class="list-icon" type="right" color="#B3B3B3" size="12"></uni-icons>
22
        </picker>
23 24 25
      </view>
    </view>
    <view class="gift-content">
chenwei's avatar
chenwei committed
26
      <view class="gift-item" v-for="item in giftList" :key="item.id" @click="toMail(item.id)">
27
        <view class="gift-image-box">
28 29 30 31 32
          <image
            class="gift-image"
            mode="cover"
            :src="locale == 'zh' ? item.imgZh : item.imgEn"
          ></image>
33 34
          <view class="gift-tag">
            <view class="tags">
chenwei's avatar
chenwei committed
35
              <image class="tag-image" src="../../../static/img/score.png"></image>
36
              <view class="tag-text">{{ item.pointsRequire }}</view>
37 38
            </view>
          </view>
chenwei's avatar
chenwei committed
39
          <view class="foot-tag">{{ $lang.lang.integral.remainder(item.quantityRemain) }}</view>
40
        </view>
chenwei's avatar
chenwei committed
41
        <view class="gift-name">{{ locale === 'zh' ? item.titleZh : item.titleEn }}</view>
42
        <view class="gift-menu">
chenwei's avatar
chenwei committed
43 44 45
          <view class="gift-menu-text" v-for="ele in item.pickMethodList" :key="ele.id">{{
            locale === 'zh' ? ele.labelZh : ele.labelEn
          }}</view>
46 47 48 49 50 51 52
        </view>
      </view>
    </view>
  </view>
</template>

<script>
53
export default {
54 55 56
  props: {
    userInfo: {
      type: Object,
chenwei's avatar
chenwei committed
57 58
      default: () => {}
    }
59
  },
60
  data() {
61 62 63 64 65 66
    return {
      giftList: [],
      data: [],
      pickerData: [[], [], []],
      pickerValue: [0, 0, 0],
      nodeId: null,
chenwei's avatar
chenwei committed
67 68
      netList: []
    }
69
  },
70 71
  computed: {
    locale() {
chenwei's avatar
chenwei committed
72 73
      return this.$lang.locale
    }
74
  },
75 76 77
  watch: {
    userInfo: {
      handler(val) {
chenwei's avatar
chenwei committed
78
        console.log(val)
79
        this.netList =
chenwei's avatar
chenwei committed
80
          this.$lang.locale === 'zh'
81
            ? [val.countryTitleZh, val.cityTitleZh]
chenwei's avatar
chenwei committed
82
            : [val.countryTitleEn, val.cityTitleEn]
83
      },
chenwei's avatar
chenwei committed
84 85
      immediate: true
    }
86 87
  },
  created() {
chenwei's avatar
chenwei committed
88 89
    this.getGift()
    this.getNet()
90
  },
91
  methods: {
92
    toMail(id) {
93
      uni.navigateTo({
chenwei's avatar
chenwei committed
94 95
        url: '/pages/order_mail/order_mail?id=' + id
      })
96 97 98 99
    },
    // 获取礼品列表
    async getGift() {
      try {
chenwei's avatar
chenwei committed
100 101 102 103 104
        const memberId = this.$store.getters.id
        const { code, data } = await this.$request.post('/app-api/ecw/reward/list', {
          memberId,
          nodeId: this.nodeId
        })
105
        if (code === 0) {
chenwei's avatar
chenwei committed
106
          this.giftList = data.list
chenwei's avatar
chenwei committed
107 108 109
          if (!this.nodeId) {
            if (data.city) {
              this.netList =
chenwei's avatar
chenwei committed
110
                this.$lang.locale === 'zh'
chenwei's avatar
chenwei committed
111
                  ? [this.userInfo.countryTitleZh, this.userInfo.cityTitleZh]
chenwei's avatar
chenwei committed
112 113 114
                  : [this.userInfo.countryTitleEn, this.userInfo.cityTitleEn]
            } else if (data.country == '130') {
              this.netList = this.$lang.locale === 'zh' ? ['中国'] : ['china']
chenwei's avatar
chenwei committed
115 116
            } else {
              this.netList =
chenwei's avatar
chenwei committed
117
                this.$lang.locale === 'zh'
chenwei's avatar
chenwei committed
118
                  ? [this.userInfo.countryTitleZh]
chenwei's avatar
chenwei committed
119
                  : [this.userInfo.countryTitleEn]
chenwei's avatar
chenwei committed
120 121
            }
          }
122
        }
chenwei's avatar
chenwei committed
123
        console.log('giftList', this.giftList)
124
      } catch (error) {
chenwei's avatar
chenwei committed
125
        console.log(error)
126 127 128 129 130
      }
    },
    // 获取网点列表
    async getNet() {
      try {
131
        const { code, data } = await this.$request.get(
chenwei's avatar
chenwei committed
132 133
          '/admin-api/member/score-rule/warehouse-tree-region-list'
        )
134
        if (code === 0) {
chenwei's avatar
chenwei committed
135 136
          this.data = data
          this.initPickerData()
137 138
        }
      } catch (error) {
chenwei's avatar
chenwei committed
139
        console.log(error)
140 141 142 143
      }
    },
    // 初始化选择器数据
    initPickerData() {
chenwei's avatar
chenwei committed
144 145 146 147 148 149 150
      if (this.data.length === 0) return
      const countries = this.data
      const cities = this.data[0].children || []
      const areas = (this.data[0].children && this.data[0].children[0].children) || []
      this.pickerData[0] = countries
      this.pickerData[1] = cities
      this.pickerData[2] = areas
151 152 153
    },
    // 选择改变
    bindPickerChange(e) {
chenwei's avatar
chenwei committed
154 155 156 157 158
      const val = e.detail.value
      this.pickerValue = val
      this.nodeId = this.pickerData[2][val[2]].id
      this.getGift()
      this.getPickerValue(val)
159 160 161
    },
    // 列改变
    bindColumnChange(e) {
chenwei's avatar
chenwei committed
162
      const { column, value } = e.detail
163 164
      const data = {
        pickerData: this.pickerData,
chenwei's avatar
chenwei committed
165 166 167
        pickerValue: this.pickerValue
      }
      data.pickerValue[column] = value
168
      if (column === 0) {
chenwei's avatar
chenwei committed
169 170 171 172 173 174 175
        const selectedCountry = this.data[value]
        const cities = selectedCountry.children || []
        const areas = (cities[0] && cities[0].children) || []
        data.pickerData[1] = cities
        data.pickerData[2] = areas
        data.pickerValue[1] = 0
        data.pickerValue[2] = 0
176
      } else if (column === 1) {
chenwei's avatar
chenwei committed
177 178 179 180 181
        const selectedCountry = this.data[data.pickerValue[0]]
        const selectedCity = selectedCountry.children[value]
        const areas = selectedCity.children || []
        data.pickerData[2] = areas
        data.pickerValue[2] = 0
182
      }
chenwei's avatar
chenwei committed
183 184 185
      this.pickerData = data.pickerData
      this.pickerValue = data.pickerValue
      this.$forceUpdate()
186 187 188
    },
    // 选择数据显示
    getPickerValue(val) {
chenwei's avatar
chenwei committed
189 190 191
      const countries = this.pickerData[0][val[0]]
      const cities = this.pickerData[1][val[1]]
      const areas = this.pickerData[2][val[2]]
192
      this.netList =
chenwei's avatar
chenwei committed
193
        this.locale === 'zh'
194
          ? [countries.labelZh, cities.labelZh, areas.labelZh]
chenwei's avatar
chenwei committed
195 196 197 198
          : [countries.labelEn, cities.labelEn, areas.labelEn]
    }
  }
}
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256
</script>

<style lang="scss" scoped>
.gift {
  width: 100%;
  height: 100%;
  box-sizing: border-box;
}
.gift-remark {
  padding: 0 32upx;
  width: 100%;
  height: 42upx;
  display: flex;
  align-items: center;
  justify-content: right;
  box-sizing: border-box;
  font-size: 20upx;
  color: red;
}

.gift-select {
  padding: 0 32upx;
  display: flex;
  width: 100%;
  height: 70upx;
  color: #b3b3b3;
  box-sizing: border-box;
  align-items: center;
  border-bottom: 2upx solid #e7e7e7;
}
.select-list {
  font-size: 20upx;
  display: flex;
  align-items: center;
}
.list-item {
  display: flex;
  align-items: center;
  margin-right: 20upx;
  &:last-child {
    margin-right: 0;
  }
}
.list-icon {
  font-weight: 600;
  margin-left: 50upx;
  &:last-child {
    margin-left: 20upx;
  }
}
.select-right {
  margin-left: auto;
  font-size: 24upx;
}
.gift-content {
  width: 100%;
  height: calc(100% - 152upx);
  padding: 32upx 32upx;
257
  gap: 2%;
258 259 260 261 262 263 264 265
  display: flex;
  flex-wrap: wrap;
  box-sizing: border-box;
  justify-content: space-between;
}
.gift-item {
  display: flex;
  flex-direction: column;
266
  width: 49%;
267 268 269 270 271
  box-sizing: border-box;
  // background-color: red;
}
.gift-image {
  margin: 0;
272 273 274
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 2;
275 276 277 278 279 280 281 282 283 284
}
.gift-name {
  margin: 0;
  display: flex;
  height: 60upx;
  font-size: 24upx;
  color: #000000;
  align-items: center;
}
.gift-menu {
285
  margin-bottom: 20upx;
286
  display: flex;
287 288 289
  gap: 10upx;
  flex-wrap: wrap;
  min-height: 58upx;
290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315
  font-size: 20upx;
  color: #b3b3b3;
  align-items: center;
}
.gift-menu-text {
  padding: 4upx 4upx;
  border: 2upx solid #ef8d15;
  font-size: 24upx;
  color: #ef8d15;
  border-radius: 20upx;
  margin-right: 10upx;
  &:last-child {
    margin-right: 0;
  }
}
.gift-image-box {
  position: relative;
}
.gift-tag {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 9;
  display: flex;
  align-items: center;
  justify-content: center;
316 317
  padding: 0 8upx;
  min-width: 80upx;
318
  height: 32upx;
319
  box-sizing: border-box;
320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359
  background: linear-gradient(#ef7e1a, #f1b009);
  transform: skewX(15deg);
  border-top-right-radius: 10upx;
  border-bottom-left-radius: 10upx;
}
.tag-image {
  width: 24upx;
  height: 24upx;
}
.tags {
  display: flex;
  align-items: center;
  justify-content: center;
  transform: skewX(-15deg);
}
.tag-text {
  margin-left: 4upx;
  font-weight: 500;
  color: #fff;
  font-size: 24upx;
}
.foot-tag {
  position: absolute;
  padding: 0 8upx;
  bottom: 0;
  right: 0;
  z-index: 9;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 110upx;
  height: 32upx;
  color: #fff;
  font-size: 22upx;
  box-sizing: border-box;
  background: linear-gradient(#ef7e1a, #f1b009);
  border-top-right-radius: 10upx;
  border-bottom-left-radius: 10upx;
}
</style>