Skip to content

Commit

Permalink
already online, the bugs in missing records after a wrong decision an…
Browse files Browse the repository at this point in the history
…d broken records when touch the empty has been fixed.
  • Loading branch information
BigSaltyFish committed May 18, 2019
1 parent 48e1682 commit 1bcb85a
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 15 deletions.
23 changes: 17 additions & 6 deletions cloudfunction/login/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
const cloud = require('wx-server-sdk')

// 与小程序端一致,均需调用 init 方法初始化
cloud.init()
cloud.init({
env: 'class-release-8cfbab'
})

// 可在入口函数外缓存 db 对象
const db = cloud.database({
Expand Down Expand Up @@ -44,12 +46,21 @@ exports.main = async (event, context) => {
gameTime: 0
}
})
await db.createCollection(`${event.userInfo.openId}-record`)
await db.collection(event.userInfo.openId + '-record').add({
data: {
_openid: event.userInfo.openId
}

let piece = {}
piece["user_id"] = event.userInfo.openId
piece["record"] = []

await db.collection('user_data').add({
data: piece
})

// await db.createCollection(`${event.userInfo.openId}-record`)
// await db.collection(event.userInfo.openId + '-record').add({
// data: {
// _openid: event.userInfo.openId
// }
// })
return {
openid: event.userInfo.openId,
score: 0,
Expand Down
13 changes: 11 additions & 2 deletions cloudfunction/uploadScore/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,19 @@ exports.main = async (event, context) => {
}
})

await db.collection(`${event.openid}-record`).add({
data: event.record
let piece = {}
piece["record"] = _.push(event.record)

await db.collection('user_data').where({
user_id: event.openid
}).update({
data: piece
})

// await db.collection(`${event.openid}-record`).add({
// data: event.record
// })

return {
event,
openid: wxContext.OPENID,
Expand Down
Binary file modified miniprogram/images/tip/diffText.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified miniprogram/images/tip/normalText.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions miniprogram/js/display/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default class ImageManager {
this.imageGet(this.cloudright, ID + 'cloudright-1.png', 'cloudright-1.png')

this.normal_cans = new Array(4)
this.getImageList(this.normal_cans, 'gabbages/normal/cans/', '.png', ID)
this.getImageList(this.normal_cans, 'gabbages/normal/cans/', '-1.png', ID)
this.dark_can_normal = new Image()
this.imageGet(this.dark_can_normal, 'cloud://classification-test-d20ada.636c-classification-test-d20ada/gabbages/normal/cans/dark.png', 'gabbages/normal/cans/dark.png')

Expand Down Expand Up @@ -145,7 +145,8 @@ export default class ImageManager {
this.fill(list)
for(let i = 1; i < list.length + 1; i++) {
let path = dir + i + format
this.imageGet(list[i - 1], id + path, path)
let real = dir + i + '.' + format.split('.')[1]
this.imageGet(list[i - 1], id + real, path)
}
}

Expand Down
6 changes: 1 addition & 5 deletions miniprogram/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import Button from './display/button.js'
const openDataContext = wx.getOpenDataContext()
const sharedCanvas = openDataContext.canvas

let counter = 0

let ctx = canvas.getContext('2d')
let databus = new DataBus()
let background = databus.images.home_page
Expand Down Expand Up @@ -227,11 +225,9 @@ export default class Main {
else if (databus.mode == 1) databus.score += 30
}

counter++
let piece = {
choose: names[classification - 1],
answer: names[enemy.classification - 1],
stamp: classification
}
if ((enemy !== lastEnemy || enemy.classification == classification) &&
classification !== 0) {
Expand Down Expand Up @@ -423,7 +419,7 @@ export default class Main {
introText,
0, 0,
introText.width, introText.height,
screenWidth / 20, 22 * screenHeight / 100 + earth.height + 8,
screenWidth / 20, 22 * screenHeight / 100 + earth.height + 13,
9 * screenWidth / 10, (9 * screenWidth / 10)*(introText.height/introText.width)
)

Expand Down

0 comments on commit 1bcb85a

Please sign in to comment.