buyClient.ftl 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. <div class="weui-btn-area">
  2. <div style="display:flex; flex-direction: row; justify-content: space-between">
  3. <div class="weui-flex__item">
  4. <div class="placeholder" style="display: inline;align-items: flex-start">当前参团:</div>
  5. <div style="display: inline;align-items: flex-start" id="Buycount"></div>
  6. </div>
  7. </div>
  8. <div class="weui-flex__item">
  9. <div style="display: inline;align-items: flex-end">状&nbsp;&nbsp;&nbsp;&nbsp;态:</div>
  10. <div style="display: inline;margin-top: 1vh;" id="myStatus"></div>
  11. </div>
  12. <div class="weui-flex__item" id="xe1">
  13. <div style="display: inline;align-items: flex-end">个人限额:</div>
  14. <div style="display: inline;margin-top: 1vh;" id="xe"></div>
  15. </div>
  16. <div class="weui-flex__item" id="tc1">
  17. <div style="display: inline;align-items: flex-end">剩余套餐(份):</div>
  18. <div style="display: inline;margin-top: 1vh;" id="tc"></div>
  19. </div>
  20. <div class="weui-flex" style="display:flex; flex-direction: row; justify-content: space-between">
  21. <div class="weui-flex__item">
  22. <div style="display: inline;align-items: flex-start">我的团购:</div>
  23. <div style="display: inline;">
  24. <input type="text" id="buyCount"
  25. style="border: 1px solid rgba(0,0,0,.2);box-sizing:border-box; border-radius: 5px; height: 5vh; width: 50%;font-size: 16px;margin-top: 1vh;"
  26. onkeyup="this.value=this.value.replace(/[^0-9-]+/,'');" min="1" maxlength="4"
  27. onchange="changeBuy()">
  28. </div>
  29. </div>
  30. </div>
  31. <div class="weui-flex__item">
  32. <div style="display: inline;">金&nbsp;&nbsp;&nbsp;&nbsp;额¥:</div>
  33. <div style="display: inline;font-size: 16px" id="myMenory"></div>
  34. </div>
  35. <div class="weui-flex">
  36. <div class="weui-flex__item">
  37. <div style="display: inline;">联系电话:</div>
  38. <div class="weui-flex__item" style="display: inline;">
  39. <input type="text" maxlength="11" id="myPhone" onkeyup="value=value.replace(/[^\d]/g,'')"
  40. maxlength=11
  41. style="border: 1px solid rgba(0,0,0,.2);box-sizing:border-box; border-radius: 5px; height: 5vh; width: 50%;font-size: 16px;margin-top: 1vh;">
  42. </div>
  43. </div>
  44. </div>
  45. <div style=" flex-direction: row; justify-content: space-between;">
  46. <div style="display: inline;align-items: flex-start"
  47. ">备&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;注:
  48. </div>
  49. <textarea id="Myremarks" class="weui-textarea" placeholder="输入内容(200字内)" rows="3"
  50. style="border: 1px solid rgba(0,0,0,.2);box-sizing:border-box; border-radius: 5px; margin-top: 1vh;"
  51. maxlength="200"></textarea>
  52. </div>
  53. <div style="display:flex; flex-direction: row; justify-content: space-between; margin-top: 1vh; margin-bottom: 5vh;">
  54. <#if type==1>
  55. <a onclick="buyBack()" href="javascript:;" class="weui-btn weui-btn_default"
  56. style="margin-top: 0;width: 30%;">返回</a>
  57. <#else>
  58. <a id="MybuyRepeal" onclick="MybuyBack()" href="javascript:;" class="weui-btn weui-btn_default"
  59. style="margin-top: 0;width: 30%;">撤销</a>
  60. <a onclick="buyBack()" href="javascript:;" class="weui-btn weui-btn_default"
  61. style="margin-top: 0;width: 30%;">返回</a>
  62. </#if>
  63. <a id="buyCommit" onclick="buyCommit()" href="javascript:;" class="weui-btn weui-btn_primary"
  64. style="margin-top: 0;width: 30%;">提交</a>
  65. </div>
  66. </div>
  67. <#include "/home/frag.foot.ftl" />
  68. <script>
  69. (function ($) {
  70. $.ajax({
  71. url: '/query/getAll/status',
  72. data: {
  73. jmId: $('#jmBuy').val(),
  74. userId: $('#buyuserId').val(),
  75. },
  76. type: 'GET',
  77. success: function (data) {
  78. console.log(data);
  79. $("#Buycount").html(data.data.count);
  80. $("#myStatus").html(getStatus(data.data.tgStatus));
  81. $("#myPhone").val(data.data.phone);
  82. if (data.data.tgMaxNum - data.data.count <= 0) {
  83. $("#tc1").toggle();
  84. } else {
  85. $("#tc").html(data.data.tgMaxNum - data.data.count);
  86. }
  87. if (data.data.myRemark != null)
  88. $('#Myremarks').text(data.data.myRemark);
  89. if (data.data.buyMoney != null)
  90. $('#buyCount').val(data.data.buyCount);
  91. if (data.data.buyMoney != null)
  92. $('#myMenory').text(Math.round(data.data.buyMoney * 10) / 10);
  93. if (data.data.tgItemNum == 0) {
  94. $('#xe1').toggle();
  95. } else {
  96. $('#xe').html(data.data.tgItemNum);
  97. }
  98. },
  99. error: function () {
  100. }
  101. });
  102. })(jQuery);
  103. <#--返回-->
  104. function buyBack() {
  105. // window.history.back();
  106. window.location.href = "/user/homeIndex.html?userId=" + $('#buyuserId').val() + "&userType=" + 1 + "&show=tuangou";
  107. }
  108. /*撤销*/
  109. function MybuyBack() {
  110. $.ajax({
  111. url: '/home/back/buyBack',
  112. data: {
  113. userId: $('#buyuserId').val(),
  114. buyCount: $('#buyCount').val(),
  115. phone: $('#myPhone').val(),
  116. myRemark: $('#Myremarks').val(),
  117. buyMoney: $('#myMenory').text(),
  118. jmId: $('#jmBuy').val(),
  119. },
  120. type: 'GET',
  121. success: function (data) {
  122. console.log(data);
  123. if (data.data == 1) {
  124. buyBack();
  125. } else {
  126. $.alert("该套餐已过截止日期或者已发货中不允许撤单");
  127. }
  128. },
  129. error: function () {
  130. }
  131. });
  132. }
  133. //提交
  134. function buyCommit() {
  135. if ($('#buyCount').val() == '' || $('#buyCount').val() == undefined) {
  136. $.alert("请填写团购数量");
  137. return;
  138. }
  139. if ($('#myPhone').val() == undefined || $('#myPhone').val() == '') {
  140. $.alert("请填写联系电话");
  141. return;
  142. }
  143. if (!(/^1[345789]\d{9}$/.test($('#myPhone').val()))) {
  144. $.alert("手机号码有误,请重填");
  145. return false;
  146. }
  147. /* if ($('#Myremarks').val() == undefined || $('#Myremarks').val() == '') {
  148. $.alert("请填写备注");
  149. return;
  150. }*/
  151. changeBuy();
  152. $.ajax({
  153. url: '/home/home/buyGroup',
  154. data: {
  155. userId: $('#buyuserId').val(),
  156. buyCount: $('#buyCount').val(),
  157. phone: $('#myPhone').val(),
  158. myRemark: $('#Myremarks').val(),
  159. buyMoney: $('#myMenory').text(),
  160. jmId: $('#jmBuy').val(),
  161. count: $('#tc').html(),
  162. },
  163. type: 'GET',
  164. async: false,
  165. success: function (data) {
  166. console.log(data.data);
  167. if (data.data == 3) {
  168. if ($("#tc").html() == 0) {
  169. $.alert("团购套餐已售空");
  170. return false;
  171. }
  172. $.alert("团购套餐只剩" + $('#tc').html() + "份");
  173. return false;
  174. } else if (data.data == 4) {
  175. $.alert("团购数量已经超过个人限额");
  176. return false;
  177. }
  178. buyBack();
  179. },
  180. error: function () {
  181. }
  182. });
  183. }
  184. //输入购买的数量
  185. function changeBuy() {
  186. if ($('#buyCount').val() < 1) {
  187. $('#buyCount').val('')
  188. $.alert('请输入大于0的整数')
  189. return;
  190. }
  191. $.ajax({
  192. url: '/query/getAll/status',
  193. data: {
  194. jmId: $('#jmBuy').val(),
  195. userId: $('#buyuserId').val(),
  196. },
  197. type: 'GET',
  198. async: false,
  199. success: function (data) {
  200. console.log(data);//
  201. $("#myMenory").html(Math.round($('#buyCount').val() * data.data.tgPrice * 10) / 10)
  202. },
  203. error: function () {
  204. }
  205. });
  206. }
  207. //1 在团 2 发货 3完成 4取消',
  208. function getStatus(v) {
  209. if (v == 1) {
  210. return "<span style='color:green;'>在团</span>";
  211. } else if (v == 2) {
  212. return "<span style='color:Black;'>发货</span>";
  213. } else if (v == 3) {
  214. return "完成";
  215. } else if (v == 4) {
  216. return "<span style='color:red;'>取消</span>";
  217. }
  218. }
  219. </script>