2023-03-22 16:51:51 +08:00

212 lines
6.5 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{extend name="common/base"/}
{block name="style"}
<style type="text/css">
.editormd-code-toolbar select {
display: inline-block
}
.editormd li {
list-style: inherit;
}
</style>
{/block}
<!-- 主体 -->
{block name="body"}
<form class="layui-form p-4">
<h3 class="pb-3">购买商品</h3>
<table class="layui-table layui-table-form">
<tr>
<td class="layui-td-gray">商品名称</td>
<td colspan="7"><input type="text" name="store_name" lay-verify="required" lay-reqText="请输入商品名称"
autocomplete="off" placeholder="请输入商品名称" class="layui-input" value="{$detail.store_name}" readonly></td>
</tr>
<tr>
<td class="layui-td-gray" style="vertical-align:top;">商品封面图</td>
<td>
<div class="layui-upload">
<!-- <button type="button" class="layui-btn layui-btn-sm" id="upload_btn_thumb">-->
<!-- 上传缩略图(尺寸:428x270)-->
<!-- </button>-->
<div class="layui-upload-list" id="upload_box_thumb"
style="overflow: hidden;">
<img src="{$detail.image}"
onerror="javascript:this.src='{__GOUGU__}/gougu/images/nonepic600x360.jpg';this.onerror=null;"
width="100" style="max-width: 100%; height:66px;"/>
<input type="hidden" name="image" value="{$detail.image}">
</div>
</div>
</td>
</tr>
<tr>
<td class="layui-td-gray">购买数量<font>*</font></td>
<td colspan="7"><input type="text" name="number" lay-verify="required|integer" lay-reqText="请输入购买数量"
autocomplete="off" placeholder="请输入购买数量" class="layui-input" value=""></td>
</tr>
</table>
<div class="pt-3">
<input type="hidden" name="product_id" value="{$detail.product_id}"/>
<button class="layui-btn layui-btn-normal preservation" lay-submit="" lay-filter="webform" >立即提交</button>
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
</div>
</form>
{/block}
<!-- /主体 -->
<!-- 脚本 -->
{block name="script"}
<script src="/static/assets/js/xm-select.js"></script>
<script>
var moduleInit = ['tool', 'tagpicker', 'tinymce'];
var group_access = "{:session('gougu_admin')['group_access']}";
var multiple_images = "{$detail['slider_image']}".split(',');
//单击图片删除图片 【注册全局函数】
function delMultipleImgs(this_img){
//获取下标
var subscript=$("#upload_box_thumb2 img").index(this_img);
//删除图片
this_img.remove();
//删除数组
multiple_images.splice(subscript, 1);
//重新排序
multiple_images.sort();
$('#upload_box_thumb2 input').attr('value', multiple_images);
//返回
return ;
}
function gouguInit() {
var form = layui.form, tool = layui.tool, tagpicker = layui.tagpicker;
form.verify({
integer: [
/^[1-9]\d*$/
, '只能输入正整数'
]
});
//上传缩略图
var upload_thumb = layui.upload.render({
elem: '#upload_btn_thumb',
url: '/admin/api/upload',
done: function (res) {
//如果上传失败
if (res.code == 1) {
layer.msg('上传失败');
return false;
}
//上传成功
$('#upload_box_thumb input').attr('value', res.data.filepath);
$('#upload_box_thumb img').attr('src', res.data.filepath);
}
});
//上传商品轮播图
var upload_thumb = layui.upload.render({
elem: '#upload_btn_thumb2',
url: '/admin/api/upload',
multiple: true,
before: function(obj){
//预读本地文件示例不支持ie8
obj.preview(function(index, file, result){
$('#upload_box_thumb2').append(`
<img src="${result}"
onerror="javascript:this.src='{__GOUGU__}/gougu/images/nonepic600x360.jpg';this.onerror=null;"
width="100" style="max-width: 100%; height:66px;" alt="${file.name}" onclick="delMultipleImgs(this)" title="点击删除"/>
`)
});
},
done: function (res) {
//如果上传失败
if (res.code == 1) {
return layer.msg('上传失败');
}
//上传成功
//追加图片成功追加文件名至图片容器
multiple_images.push(res.data.filepath);
$('#upload_box_thumb2 input').attr('value', multiple_images);
// $('#upload_box_thumb2 img').attr('src', res.data.filepath);
}
});
var editor = layui.tinymce;
var edit = editor.render({
selector: "#container_content",
height: 500
});
//监听提交
form.on('submit(webform)', function (data) {
// 单击之后提交按钮不可选,防止重复提交
var DISABLED = 'layui-btn-disabled';
// 增加样式
$('.preservation').addClass(DISABLED);
// 增加属性
$('.preservation').attr('disabled', 'disabled');
let callback = function (e) {
if (e.code == 200) {
// 成功的时候
/** 把生成的二维码放到页面上 */
var url = e.data.html;
/** 弹出二维码 **/
layer.open({
//type:1 表示页面层
type: 1,
title: '扫码支付',
//是否点击遮罩关闭
shadeClose: false,
//样式类名,可以自定义弹窗样式
skin:'demo_share',
// 去掉关闭按钮
closeBtn :'',
//弹层外区域
shade: 0.3,
maxmin: false, //开启最大化最小化按钮
//宽高
area: ['200px','220px'],
//内容
content: "<img src='"+url+"' alt='' style='margin-left: 20px;'>",
});
/** 设置定时器, 即一弹出二维码就开始不断请求查看支付状态, 直到收到支付成功的返回, 再终止定时器 **/
var timer = setInterval(function () {
/** 在这里请求微信支付状态的接口 **/
//ajax。必填参数'options':请求参数,对象,'callback':成功回调函数
let options = {
url: '/admin/store_product/paid',
type: 'get',
data: {
out_trade_no: e.data.order_sn,
}
};
let callback = function(res) {
if (res.code == 200) {
layer.msg('支付成功',{time:2000,icon:6});
/** 如果支付成功, 就取消定时器, 并重新加载页面 */
window.clearInterval(timer);
// 关闭所有层
tool.sideClose(2000);
// window.location.reload();
}
}
tool.ajax(options, callback);
}, 3000);
}else{
layer.msg(e.msg,{icon:5});
// 失败的时候
// 单击之后提交按钮不可选,防止重复提交
var DISABLED = 'layui-btn-disabled';
$('.preservation').removeClass(DISABLED);
$('.preservation').removeAttr('disabled');
}
}
tool.post("/admin/store_product/place_order", data.field, callback);
return false;
});
}
</script>
{/block}
<!-- /脚本 -->