meal.php 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. {extend name="public/container"}
  2. {block name="head_top"}
  3. <style>
  4. .layui-input-block button {
  5. border: 1px solid rgba(0, 0, 0, 0.1);
  6. }
  7. .layui-card-body {
  8. padding-left: 10px;
  9. padding-right: 10px;
  10. }
  11. .layui-card-body p.layuiadmin-big-font {
  12. font-size: 36px;
  13. color: #666;
  14. line-height: 36px;
  15. padding: 5px 0 10px;
  16. overflow: hidden;
  17. text-overflow: ellipsis;
  18. word-break: break-all;
  19. white-space: nowrap;
  20. }
  21. .layui-fluid .layui-row . {
  22. position: absolute;
  23. right: 15px;
  24. }
  25. .layuiadmin-badge {
  26. top: 50%;
  27. margin-top: -9px;
  28. color: #01AAED;
  29. }
  30. .layuiadmin-span-color i {
  31. padding-left: 5px;
  32. }
  33. .layui-card.card {
  34. border: 2px solid #F2F2F2;
  35. border-radius: 2%;
  36. }
  37. .layui-card.checkcard {
  38. border: 2px solid #F47822;
  39. border-radius: 5px;
  40. }
  41. .block-rigit button {
  42. width: 100px;
  43. letter-spacing: .5em;
  44. line-height: 28px;
  45. }
  46. .layui-form-item {
  47. margin-bottom: .5rem;
  48. }
  49. .layui-form-item .code {
  50. width: 15rem;
  51. }
  52. .layui-form-item .code img {
  53. width: 100%;
  54. height: 100%;
  55. }
  56. </style>
  57. <script src="{__PLUG_PATH}echarts.common.min.js"></script>
  58. {/block}
  59. {block name="content"}
  60. <div class="layui-fluid" id="app" v-cloak="">
  61. <div class="layui-row layui-col-space15">
  62. <div class="layui-card">
  63. <div class="layui-card-header">
  64. 购买服务
  65. </div>
  66. <div class="layui-tab layui-tab-brief" lay-filter="tab">
  67. <ul class="layui-tab-title">
  68. <li lay-id="list" class="layui-this" @click="changeMealType('sms')">短信
  69. </li>
  70. </ul>
  71. </div>
  72. <div class="layui-row">
  73. <div class="layui-card-body layui-col-space10">
  74. <div class="layui-col-sm1 layui-col-md2" v-for="(item,index) in priceList"
  75. @click="checkMeal(item,index)">
  76. <div class="layui-card" :class="param == index ? 'checkcard' : 'card'">
  77. <div class="layui-card-body" style="padding: 27px 15px 0;">
  78. <p style="text-align: center;color: #F47822;font-size: 30px;line-height: 30px;">{{
  79. item.num }}条</p>
  80. </div>
  81. <div class="layui-card-header">
  82. <p style="text-align: center;color: #C2C5BE;font-size: 16px;">¥{{ item.price }}</p>
  83. </div>
  84. </div>
  85. </div>
  86. </div>
  87. </div>
  88. </div>
  89. <div class="layui-row layui-col-space15">
  90. <div class="layui-card" v-show="checked">
  91. <div class="layui-card-header">
  92. 立即支付
  93. </div>
  94. <div class="layui-card-body">
  95. <div class="layui-row">
  96. <form class="layui-form" action="">
  97. <div class="layui-form-item">
  98. <label class="layui-form-label">短信账户:</label>
  99. <div class="layui-input-block">
  100. <span style="font-size: 24px;line-height: 33px;">{$info['account']}</span>
  101. </div>
  102. </div>
  103. <div class="layui-form-item">
  104. <label class="layui-form-label">剩余条数:</label>
  105. <div class="layui-input-block">
  106. <span style="font-size: 24px;line-height: 33px;">{$info['sms']['num']} 条</span>
  107. </div>
  108. </div>
  109. <div class="layui-form-item">
  110. <label class="layui-form-label">支付方式:</label>
  111. <div class="layui-input-block">
  112. <button type="button" class="layui-btn" :class="payType == 'weixin'? 'layui-btn-normal' : 'layui-btn-primary'" @click="changeType('weixin')">微信支付
  113. </button>
  114. <!-- <button type="button" class="layui-btn" :class="payType == 'alipay'? 'layui-btn-normal' : 'layui-btn-primary'" @click="changeType('alipay')">支付宝-->
  115. <!-- </button>-->
  116. </div>
  117. </div>
  118. <div class="layui-form-item">
  119. <label class="layui-form-label">充值条数:</label>
  120. <div class="layui-input-block">
  121. <span style="font-size: 24px;line-height: 33px;">{{ checked.num }} 条</span>
  122. </div>
  123. </div>
  124. <div class="layui-form-item">
  125. <label class="layui-form-label">支付金额:</label>
  126. <div class="layui-input-block">
  127. <p style="line-height: 33px;font-size: 16px;color: #F47822;">¥{{ checked.price
  128. }}</p>
  129. </div>
  130. </div>
  131. <div class="layui-form-item" v-show="code.code_show">
  132. <div class="layui-input-block code" >
  133. <div id="qrcode" style="width:100px; height:100px; margin-top:15px;"></div>
  134. </div>
  135. <div class="layui-input-block">
  136. <span>
  137. 支付码过期时间:{{code.invalid}}
  138. </span>
  139. </div>
  140. </div>
  141. <div class="layui-form-item" v-else>
  142. <span>您尚未开通短信服务,请先开启<a href="{:Url('setting.systemPlat/sms_open')}" style="color: rgb(244, 120, 34);font-size: 20px;">开通服务</a></span>
  143. </div>
  144. </form>
  145. </div>
  146. </div>
  147. </div>
  148. </div>
  149. </div>
  150. </div>
  151. <script src="{__ADMIN_PATH}js/layuiList.js"></script>
  152. <script src="{__ADMIN_PATH}js/qrcode.js"></script>
  153. <script>
  154. require(['vue'], function (Vue) {
  155. new Vue({
  156. el: "#app",
  157. data: {
  158. type: 'sms',
  159. number: 0,
  160. send_total: 0,
  161. option: {},
  162. status: '',
  163. data: '',
  164. title: '全部商品',
  165. myChart: {},
  166. showtime: false,
  167. priceList: [],
  168. checked: false,
  169. param: '',
  170. payType: 'weixin',
  171. code: '',
  172. qrcode: ''
  173. },
  174. watch: {
  175. "param": function (newVal) {
  176. let that = this;
  177. that.checked = that.priceList[newVal];
  178. that.param = newVal;
  179. that.getCode();
  180. }
  181. },
  182. methods: {
  183. checkMeal: function (item, index) {
  184. this.param = index;
  185. },
  186. changeMealType: function (val) {
  187. if (val != this.type) {
  188. this.type = val;
  189. this.getLackList();
  190. }
  191. },
  192. getLackList: function () {
  193. var that = this;
  194. var index = layList.layer.load(2, {shade: [0.3, '#fff']});
  195. layList.baseGet(layList.Url({a: 'get_meal', p: {type: that.type}}), function (res) {
  196. layList.layer.close(index);
  197. that.priceList = res.data.data;
  198. if (that.priceList.length > 0) {
  199. that.checked = res.data[0];
  200. that.param = 0;
  201. }
  202. }, function (err) {
  203. layList.layer.close(index);
  204. });
  205. },
  206. changeType: function (val) {
  207. if (val != this.payType) {
  208. this.payType = val;
  209. this.getCode();
  210. }
  211. },
  212. getCode: function () {
  213. let that = this;
  214. let index = layList.layer.load(2, {shade: [0.3, '#fff']});
  215. layList.basePost(layList.Url({a: 'pay'}), {
  216. type: that.checked.type,
  217. num: that.checked.num,
  218. price: that.checked.price,
  219. meal_id: that.checked.id,
  220. pay_type: that.payType
  221. }, function (res) {
  222. layList.layer.close(index);
  223. that.code = res.data;
  224. that.qrcode.makeCode(res.data.qr_code);
  225. }, function (err) {
  226. layList.layer.close(index);
  227. });
  228. },
  229. },
  230. mounted: function () {
  231. this.getLackList();
  232. this.$nextTick(function () {
  233. this.qrcode = new QRCode(document.getElementById("qrcode"), {
  234. width : 100,
  235. height : 100
  236. });
  237. })
  238. }
  239. });
  240. })
  241. </script>
  242. {/block}