| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384 |
- <?php
- use common\services\xhWifiService;
- use common\components\util;
- ?>
- <div class="page-title">
- <div class="title-env">
- <h1 class="title">店铺管理</h1>
- </div>
- <div class="breadcrumb-env">
- <ol class="breadcrumb bc-1">
- <li>
- <a href="/"><i class="fa-home"></i>Home</a>
- </li>
- <li>
- <a href="javascript:void(0)">商城管理</a>
- </li>
- <li class="active">
- <strong>店铺管理</strong>
- </li>
- </ol>
- </div>
- </div>
- <div class="panel panel-default">
- <div class="panel-body">
- <div class="dataTables_wrapper form-inline dt-bootstrap no-footer">
- <div class="row">
- <form action="" method="GET">
- <div class="col-xs-6" style="width:90%;">
- <div class="dataTables_length">
- <a href="javascript:void(0)" name="" class="btn btn-secondary btn-single" id="init-store" style="">新建门店</a>
- </div>
- </div>
- </form>
- </div>
-
- <div class="table-responsive">
- <table class="table table-bordered table-striped table-hover" >
- <thead>
- <tr class="active">
- <th class="no-sorting hidden-xs"><input type="checkbox"></th>
- <th class="hidden-xs">ID</th>
- <th>门店名称</th>
- <th class="hidden-xs">图片</th>
- <th class="hidden-xs">地址</th>
- <th class="hidden-xs">电话</th>
- <th class="hidden-xs">创建时间</th>
- <th class="hidden-xs">状态</th>
- <th>操作</th>
- </tr>
- </thead>
- <tbody class="middle-align">
- <?php if(!empty($shop)){ foreach($shop as $key => $val){
- $shopId = $val['id'];
- $wifi = [];
- if(!empty($shopId)){
- $wifi = xhWifiService::getListByShopId($shopId);
- }
- ?>
- <tr>
- <td class="hidden-xs"><input type="checkbox"></td>
- <td class="hidden-xs"><?= $val['id'] ?></td>
- <td><?= $val['branchName'] ?></td>
- <td class="hidden-xs"> </td>
- <td class="hidden-xs"><?= $val['shopAddress'] ?></td>
- <td class="hidden-xs"><?= $val['telephone'] ?></td>
- <td class="hidden-xs"><?= date("Y-m-d H:i",strtotime($val['createTime'])) ?></td>
- <td class="hidden-xs"><?php util::echoStatus($val['status'], 'xhShop')?></td>
- <td>
- <a href="javascript:void(0)" class="btn btn-secondary btn-sm btn-icon icon-left free-wifi-btn" shop_id="<?= $val['shopId']?>">WIFI设置</a>
- <a href="javascript:void(0)" onclick="createQrCode(<?= $val['shopId'] ?>, <?= $val['status']?>, $(this));" data-url="/merchant/gathering-url?shopId=<?= $val['shopId']?>" class="btn btn-secondary btn-sm btn-icon icon-left">收款码 </a>
- <?php
- if($val['status'] == 2){
- ?>
- <a href="javascript:void(0)" onclick="createQrCode(<?= $val['shopId'] ?>, <?= $val['status']?>, $(this));" data-url="/merchant/gathering-url?shopId=<?= $val['shopId']?>" class="btn btn-secondary btn-sm btn-icon icon-left">收款码 </a>
- <?php
- }
- ?>
- </td>
- </tr>
- <?php } }?>
- </tbody>
- </table>
- </div>
- <div class="row">
- <div>
- <div class="dataTables_paginate paging_simple_numbers" style="float:right;padding-top:0px;margin-right:15px;">
- <?= $paging ?>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- <!-- footer -->
- <?php
- use backend\widgets\FooterWidget;
- ?>
- <?= FooterWidget::widget()?>
- <!-- footer -->
- <script>
- $(function(){
- //创建门店操作
- $("#init-store").click(function(){
- $('#create-store-model').modal('show');
- });
- //确认创建门店
- $("button[name=createStoreConfirmButton]").click(function(){
- var storeName = $("#create-store-model .modal-body input[name=storeName]").val();
- return false;
- if(storeName.length <= 0){
- xhPopMsg('请输入分店名称',1300);
- return;
- }
- $("button[name=createStoreConfirmButton]").attr('submitStatus','yes');
- setTimeout(function(){
- $("button[name=createStoreConfirmButton]").attr('submitStatus','no');
- },5000);
- $.ajax({
- type: "POST",
- url: "/shop/apply-store",
- data:{'storeName':storeName, '_csrf':"<?= Yii::$app->request->csrfToken;?>"},
- dataType: "json",
- //在请求之前调用的函数
- beforeSend:function(){
- xhPopMsg('门店生成中…');
- },
- success:function(data){
- console.log(data);
- if(data.errcode == 0){
- xhPopMsg('门店创建成功!');
- setTimeout(function(){
- window.location.reload();
- },1000);
- }else{
- xhPopMsg('出错,原因:'+data.errmsg,1300);
- }
- },
- //调用执行后调用的函数
- complete: function(XMLHttpRequest, textStatus){
- //alert(XMLHttpRequest.responseText);
- //alert(textStatus);
- //HideLoading();
- },
- //调用出错执行的函数
- error: function(){
- //请求出错处理
- }
- });
- });
- $.getWifiCode = function(shopId){
- var wifiData;
- $.ajax({
- url: '/shop/get-wifi-code',
- type: 'POST',
- data: {'_csrf':"<?= Yii::$app->request->csrfToken;?>", 'shopId':shopId},
- dataType: 'json',
- async: false,
- success:function(data){
- if(data.code == 'success'){
- //console.log(data.data);
- wifiData = data.data;
- }else if(data.code == 'downLoadImgError') {
- xhPopMsg(data.msg);
- }else{
- //xhPopMsg(data.msg, 1300);
- xhPopMsg('请先点击 免费WIFI设置!');
- }
- },
- error:function(){
- xhPopMsg('request error');
- }
- });
- return wifiData;
- };
- //wifi密码设置
- $(".free-wifi-btn").click(function(){
- var shopId = $(this).attr('shop_id');
- var wifiData = $.getWifiCode(shopId);
- if(wifiData.ssid != ''){
- $("#set-wifi-model .form-horizontal input[name=wifiName]").val(wifiData.ssid);
- }
- if(wifiData.ssidPassword != ''){
- $("#set-wifi-model .form-horizontal input[name=wifiCode]").val(wifiData.ssidPassword);
- }
- if(wifiData.ssid != '' && wifiData.ssidPassword != ''){
- $("button[name=wifiConfirmBtn]").html('修改');
- }
- $("#set-wifi-model .form-horizontal input[name=shopId]").val(shopId);
- $('#set-wifi-model').modal('show');
- });
- //ssid和密码必须有一个以大写字母“WX”开头
- $("button[name=wifiConfirmBtn]").click(function(){
- var wifiName = $("#set-wifi-model .form-horizontal input[name=wifiName]").val();
- var wifiCode = $("#set-wifi-model .form-horizontal input[name=wifiCode]").val();
- var shopId = $("#set-wifi-model .form-horizontal input[name=shopId]").val();
- var action = 'add';//默认新增创建
- if(wifiName.length <= 0){
- xhPopMsg('请输入 WIFI 名称', 1500);
- return;
- }
- if(wifiCode.length <= 0){
- xhPopMsg('请输入 WIFI 密码', 1500);
- return;
- }
- if(wifiCode.length < 8){
- xhPopMsg('不少于8个字符', 1500);
- return;
- }
- if(wifiCode.length > 32){
- xhPopMsg('最多24个字符', 1500);
- return;
- }
- if(wifiCode.substring(0, 1) != 'W' || wifiCode.substring(1, 2) != 'X'){
- xhPopMsg('WIFI 密码必须以 WX 字母开头', 1500);
- $("#set-wifi-model .form-horizontal input[name=wifiCode]").val('WX');
- return;
- }
- $("button[name=wifiConfirmBtn]").attr('disabled', true);
- if($(this).html() == '修改'){
- action = 'update';
- }
- $.ajax({
- type: "POST",
- url: "/shop/create-wifi",
- data:{'wifiName':wifiName, 'wifiCode': wifiCode, 'shopId': shopId, 'action': action,'_csrf':"<?= Yii::$app->request->csrfToken;?>"},
- dataType: "json",
- //在请求之前调用的函数
- beforeSend:function(){
- xhPopMsg('wifi设置中…');
- },
- success:function(data){
- console.log(data);
- if(data.code == 'success'){
- xhPopMsg('微信wifi'+data.msg);
- $('#set-wifi-model').modal('hide');
- }else{
- xhPopMsg(data.msg, 1500);
- }
- },
- //调用执行后调用的函数
- complete: function(XMLHttpRequest, textStatus){
- },
- //调用出错执行的函数
- error: function(){
- //请求出错处理
- xhPopMsg('request error');
- }
- });
- $("button[name=wifiConfirmBtn]").attr('disabled', false);
- });
- });
- function delStore(id, shopId, currentObj) {
- var title = '提示';
- var response = currentObj.attr('data-msg');
- var url = currentObj.attr('data-url');
- $('#modal-common .modal-title').html(title);
- $('#modal-common .modal-body').html(response);
- $('#modal-common .btn-white').html('取消');
- $('#modal-common .btn-info').html('确定');
- $('#modal-common').modal('show', {
- backdrop: 'static'
- });
- $('#modal-common .btn-info').on('click', function() {
- $.ajax({
- type: "POST",
- url: url,
- data: {
- 'poiId': id,
- 'shopId': shopId,
- '_csrf': "<?=Yii::$app->request->csrfToken;?>"
- },
- dataType: "json",
- success: function(data) {
- if (data.code == 'success') {
- $('#modal-common').modal('hide');
- currentObj.parents('tr').remove();
- xhPopMsg(data.msg);
- } else {
- xhPopMsg(data.msg+': '+data.data.errmsg);
- }
- },
- error: function(msg) {
- xhPopMsg('error');
- }
- })
- })
- }
- function createQrCode(shopId, status, currentObj){
- var wifiData = $.getWifiCode(shopId);
- var suffixUrl = currentObj.attr('data-url');
- if(wifiData.ssid == '' || wifiData.ssidPassword == ''){
- xhPopMsg('请先点击 免费WIFI设置!', 2000);
- return;
- }
- if(status != 2){
- xhPopMsg('门店审核通过才能设置哦!', 2000);
- //return;
- }
- if(wifiData.avaibleDev == 0){
- xhPopMsg('请先把无线路由器改设成 之前生成的wifi名称与密码,并连接上', 3000);
- return;
- }
- var webUrl = "<?= Yii::$app->request->hostInfo; ?>";
- //alert(webUrl + suffixUrl);
- window.location.href = webUrl + suffixUrl;
- }
- </script>
- <!-- modal 创建门店 -->
- <div class="modal fade" id="create-store-model" >
- <div class="modal-dialog" style="height:350px;">
- <div class="modal-content">
- <div class="modal-header">
- <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
- <h4 class="modal-title">创建门店</h4>
- </div>
- <div class="modal-body">
- <div class="row">
- <div class="col-md-6">
- <div class="form-group">
- <label for="field-1" class="control-label">门店名:</label>
- <input type="tel" class="form-control" placeholder="" name="storeName" value="">
- <ban style="font-size: 11px; color: red;">* 不应包含地区信息,不应与门店名有重复<ban>
- </div>
- </div>
- </div>
- </div>
- <div class="modal-footer">
- <button type="button" class="btn btn-info" name="createStoreConfirmButton">确认</button>
- <button type="button" class="btn btn-white" data-dismiss="modal">取消</button>
- </div>
- </div>
- </div>
- </div>
- <!-- modal wifi密码设置 -->
- <div class="modal fade" id="set-wifi-model" >
- <div class="modal-dialog">
- <div class="modal-content">
- <div class="modal-header">
- <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
- <h4 class="modal-title">wifi密码设置</h4>
- </div>
- <form class="form-horizontal" role="form" style="margin:12px 20px 8px -5px;">
- <input type="hidden" name="shopId">
- <div class="form-group">
- <label for="wifiname" class="col-sm-3 control-label">WIFI名称:</label>
- <div class="col-sm-8">
- <input type="text" class="form-control" name="wifiName" placeholder="WiFi名称(32个字符以内)">
- </div>
- </div>
- <div class="form-group">
- <label for="code" class="col-sm-3 control-label">WIFI密码:</label>
- <div class="col-sm-8">
- <input type="text" class="form-control" name="wifiCode" placeholder="以大写字母“WX”开头(不能包含中文字符)">
- </div>
- </div>
- </form>
- <div class="modal-footer">
- <button type="button" class="btn btn-info" name="wifiConfirmBtn">确认</button>
- <button type="button" class="btn btn-white" data-dismiss="modal">取消</button>
- </div>
- </div>
- </div>
- </div>
|