Commit 66e68b40 by 尹烁恒

完成开发

parent 1d92be17
......@@ -41,6 +41,7 @@
</div>
</div>
<div class="submit-field">
<img src="../../assets/img/line.png" class="line"/>
<button class="button-submit" open-type="getUserInfo" @getuserinfo="handleGetUserInfo"></button>
</div>
</div>
......@@ -62,7 +63,7 @@ export default {
// 性能触发.所有的list只存key
return {
_cache: {},
p_index: 1,
p_index: 0,
itemList: [],
brandList: [],
hasFoucs: false,
......@@ -75,20 +76,32 @@ export default {
this.getConfig()
this.login()
},
onLoad() {
},
methods: {
initData() {
this._cache = {}
},
resetData() {
this.p_index = 0
this.hasFoucs = false
this.searchValue = ''
this.searchPage = 1
this.getConfig()
},
login() {
const that = this
wx.login({
success(res) {
that._jscode = res.code
wx.setStorageSync('hasLogin', true)
},
fail() {
that.login()
}
return new Promise((resolve, reject) => {
wx.login({
success(res) {
that._jscode = res.code
wx.setStorageSync('hasLogin', true)
resolve()
},
fail() {
resolve(that.login())
}
})
})
},
handleInputFoucs() {
......@@ -107,14 +120,15 @@ export default {
if (obj.loaded) return
this.fetchDetail(this.brand, obj.page)
},
handleGetUserInfo(e) {
async handleGetUserInfo(e) {
console.log(e)
if (e.target.errMsg === 'getUserInfo:ok') {
if (wx.getStorageSync('hasLogin')) {
this.handleSubmit()
return
this.getUserInfo(e.target)
} else {
await this.login()
this.getUserInfo(e.target)
}
this.getUserInfo(e.target)
} else {
wx.showModal({
title: '提示',
......@@ -130,7 +144,7 @@ export default {
js_code: this._jscode
})
.then(res => {
console.log(res)
console.log(res.data.token, 'token')
setAuthorization(res.data.token)
// 调用提交接口
this.handleSubmit()
......@@ -156,7 +170,7 @@ export default {
this._cache[name].activeList = []
}
console.log(this._cache)
this.fetchDetail(this.brandList[1].name)
this.fetchDetail(this.brandList[0].name)
})
.catch(res => {
console.log(res)
......@@ -175,13 +189,60 @@ export default {
array = array.concat(...phoneArray)
}
})
console.log(array, 'submit array')
console.log(JSON.stringify(array), 'json stringify array')
this.initData()
wx.redirectTo({
url: '/pages/logs/main'
fly.post('commit', {
mobiles: JSON.stringify(array)
})
.then(async res => {
console.log('提交之后的数据', res)
await this.fetchImage(res.data)
// 重置数据
this.resetData()
})
.catch(e => {
console.log('异常')
})
},
fetchImage(data) {
// 精简数据
wx.showLoading({
title: '加载中',
mask: true
})
wx.request({
url: 'https://test-api.wxagame.com/game-mobile/api/v1/image',
method: 'POST',
header: {
'content-type': 'application/octet-stream'
},
data: {
data: JSON.stringify(data)
},
success: function (res) {
var data = res.data
console.log(res.statusCode)
if (res.statusCode === 200) {
store.commit('setImage', 'data:image/png;base64,' + data)
wx.hideLoading()
wx.redirectTo({
url: `/pages/logs/main`
})
} else {
wx.hideLoading()
wx.showToast({
title: '生成失败',
icon: 'fail'
})
}
},
fail() {
wx.hideLoading()
wx.showToast({
title: '生成失败',
icon: 'fail'
})
}
})
this.initData()
},
// 获取详情
fetchDetail(brand = '', page = 1) {
......@@ -251,17 +312,13 @@ export default {
this.fetchDetail(brand)
this.p_index = index
},
// 点击右侧
handleItemCell(option) {
// 使用一个activeList去维护激活的id
console.log(option)
// 此时显然没有触发mutated,itemList的引用没变。not mutated,就不会update更不会re-render
option.is_active = !option.is_active
const status = option.is_active
const num = status ? 1 : -1
const num = option.is_active ? 1 : -1
// 如果brands有多个分类,做排除自身意外的激活或移除操作
if (option.brands.length > 1) {
// 如果包括·经典·,经典的total需要去响应
// num移入外层判断,避免在forEach过程判断
if (num > -1) {
// 过滤出不属于当前brand的brands
option.brands.filter(item => item !== this.brand).forEach(brand => {
......@@ -459,6 +516,13 @@ export default {
}
.submit-field {
flex: 0 0 200rpx;
text-align: center;
}
.line {
position: relative;
margin: 0 auto;
width: 700rpx;
height: 6rpx;
}
.button-submit {
width: 489rpx;
......
......@@ -7,7 +7,6 @@ app.$mount()
// 这里才会导出page.json
export default {
config: {
navigationBarTitleText: '布里吉',
disableScroll: true
}
}
......@@ -7,7 +7,6 @@ app.$mount()
// 这里才会导出page.json
export default {
config: {
navigationBarTitleText: '布里吉',
disableScroll: true
}
}
<template>
<div>
<img src="../../assets/img/log-bg.jpg" class="log-bg"/>
<img :src="path" class="log-bg"/>
<div class="fixed">
<ul class="list-container">
<li class="list-item">
......@@ -15,7 +15,7 @@
</template>
<script>
import store from '@/store'
export default {
onShareAppMessage() {
return {
......@@ -25,6 +25,13 @@ export default {
},
components: {
},
onLoad() {
},
computed: {
path() {
return store.state.indexPage.path
}
},
data () {
return {
}
......
......@@ -3,3 +3,9 @@ import App from './index'
const app = new Vue(App)
app.$mount()
export default {
config: {
disableScroll: true
}
}
......@@ -16,6 +16,7 @@ fly.config.baseURL = 'https://test-api.wxagame.com/game-mobile/api/v1/'
// add token
fly.interceptors.request.use((config, promise) => {
log(config, 'request config')
console.log(getAuthorization())
if (getAuthorization()) {
config.headers['Authorization'] = getAuthorization()
}
......
......@@ -23,11 +23,11 @@ const counterModule = {
const logsModule = {
state: {
log: 10
path: ''
},
mutations: {
increment (state) {
state.log += 1
setImage (state, payload) {
state.path = payload
}
}
}
......
File added
static/index-bg.jpg

571 KB | W: | H:

static/index-bg.jpg

242 KB | W: | H:

static/index-bg.jpg
static/index-bg.jpg
static/index-bg.jpg
static/index-bg.jpg
  • 2-up
  • Swipe
  • Onion skin
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment