100 lines
2.5 KiB
JavaScript
100 lines
2.5 KiB
JavaScript
let urlPrefix = getUrlPrefix()
|
|
let browser = checkVersion()
|
|
let env = EnvCheck();
|
|
if (env == 'test') {
|
|
new VConsole();
|
|
}
|
|
// 封裝layer消息提醒框
|
|
let layerIndex
|
|
const showLoading = (content = '加載中...') => {
|
|
layer.open({
|
|
type: 2,
|
|
shadeClose: false,
|
|
content,
|
|
success (e) {
|
|
layerIndex = $(e).attr('index')
|
|
}
|
|
})
|
|
}
|
|
const hideLoading = (index) => {
|
|
layer.close(index)
|
|
}
|
|
const toastMsg = (content = '操作完成', time = 2) => {
|
|
layer.open({
|
|
content,
|
|
time,
|
|
skin: 'msg'
|
|
})
|
|
}
|
|
// 初始化函數
|
|
$(function () {
|
|
setTimeout(function () {
|
|
getInfoFromClient()
|
|
setTimeout(function () {
|
|
// 頁面全屏
|
|
if (browser.app) {
|
|
if (browser.android) {
|
|
window.androidJsObj.initShowNav(false)
|
|
} else {
|
|
window.webkit.messageHandlers.initShowNav.postMessage(0)
|
|
}
|
|
};
|
|
// 頂部返回事件
|
|
$('.back').click(() => {
|
|
if (browser.android) {
|
|
window.androidJsObj.closeWebView()
|
|
} else {
|
|
window.webkit.messageHandlers.closeWebView.postMessage(null)
|
|
}
|
|
})
|
|
swiperFun();
|
|
}, 100)
|
|
})
|
|
})
|
|
// 接口
|
|
function get () {
|
|
showLoading()
|
|
networkRequest({
|
|
type: 'GET',
|
|
url: urlPrefix + '/seekElfin/product/list',
|
|
data: {},
|
|
success (res) {
|
|
if (res.code === 200) {
|
|
|
|
} else {
|
|
toastMsg(res.message)
|
|
}
|
|
hideLoading(layerIndex)
|
|
},
|
|
error (err) {
|
|
hideLoading(layerIndex)
|
|
toastMsg('網絡錯誤,請退出重進')
|
|
}
|
|
})
|
|
}
|
|
// 播放svg
|
|
function svgaFun () {
|
|
player1 = new SVGA.Player('.star_in');
|
|
parser1 = new SVGA.Parser('.star_in');
|
|
parser1.load('./images/star.svga', function (videoItem) {
|
|
player1.loops = 1;
|
|
player1.clearsAfterStop = false;
|
|
player1.setVideoItem(videoItem);
|
|
player1.startAnimation();
|
|
player1.setContentMode('AspectFill')
|
|
player1.onFinished(() => {
|
|
})
|
|
})
|
|
}
|
|
// 定情信物礼物轮播
|
|
function swiperFun () {
|
|
var mySwiper = new Swiper('.swiper', {
|
|
direction: "vertical",
|
|
loop: true,
|
|
autoplay: {
|
|
delay: 2000,//3秒切换一次
|
|
disableOnInteraction: false
|
|
}
|
|
})
|
|
}
|