master v0.0.0
Evan Chen 2022-01-04 23:45:55 +08:00
parent 2f35f8c4b0
commit 4c49538619
2 changed files with 16 additions and 3 deletions

View File

@ -77,7 +77,7 @@ func ApiPurchase(event *linebot.Event) {
for i, salse := range salses {
columns[i] = linebot.NewCarouselColumn(
salse.Img, salse.Name, salse.Brief,
linebot.NewPostbackAction("讓我幫你", "sales="+salse.Name, "讓我幫你", ""),
linebot.NewPostbackAction("讓我幫你", "sales="+salse.Name+"&"+event.Postback.Data, "讓我幫你", ""),
)
}
template := linebot.NewCarouselTemplate(columns...)

View File

@ -8,8 +8,9 @@ import (
)
func ApiSelectSales(event *linebot.Event) {
data := event.Postback.Data
data = strings.TrimPrefix(data, "sales=")
args := strings.Split(event.Postback.Data, "&")
data := strings.TrimPrefix(args[0], "sales=")
pname := strings.TrimPrefix(args[1], "purchase=")
sales := &Sales{}
DB.First(sales, "name = ?", data)
@ -20,6 +21,18 @@ func ApiSelectSales(event *linebot.Event) {
msg := linebot.NewFlexMessage("很高興為您服務!", tmp)
sticker := linebot.NewStickerMessage("1070", "17852")
SendMessage(event.ReplyToken, event.Source.UserID, msg, sticker)
prod := &Product{}
DB.First(prod, "name = ?", pname)
go func() {
// sales called and start proccess
SendMessage("", event.Source.UserID)
// proccessing
//proccess complete
}()
}
var greet string = `