evaluate.html 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
  6. <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
  7. <title></title>
  8. <link rel="stylesheet" type="text/css" href="../../css/api.css" />
  9. <link rel="stylesheet" type="text/css" href="../../css/weui.min.css" />
  10. <link rel="stylesheet" type="text/css" href="../../css/iconfont.css" />
  11. <link rel="stylesheet" type="text/css" href="../../css/star-rating-svg.css?v=1.2" />
  12. <link rel="stylesheet" type="text/css" href="../../css/style.css?v=1.2" />
  13. <style>
  14. body{}
  15. .evaluate-item{
  16. height: 1rem;
  17. line-height: 1rem;
  18. font-size: 0.28rem;
  19. background: #ffffff;
  20. position: relative;
  21. }
  22. .my-rating{
  23. position:absolute;
  24. left: 1rem;
  25. top: 0.3em;
  26. }
  27. .back-item{
  28. width:100%;
  29. padding:10px;
  30. text-align:center;
  31. box-sizing: border-box;
  32. }
  33. .back-item img{
  34. width:20px;
  35. }
  36. textarea{
  37. width:100%;
  38. height: 2rem;
  39. font-size: 0.28rem;
  40. line-height: 0.37rem;
  41. padding:5px;
  42. box-sizing: border-box;
  43. -webkit-appearance: none;
  44. color:#666666;
  45. }
  46. .my-rating .jq-star {
  47. width: 0.4rem !important;
  48. height: 0.4rem !important;
  49. }
  50. .close_btn {
  51. position: absolute;
  52. margin-left: -0.52rem;
  53. color: #d9251c;
  54. }
  55. .image-list .close_btn.iconfont.icon-guanbi:before {
  56. /*position: absolute;*/
  57. /*margin-left: 1.2rem;*/
  58. }
  59. .image-list .img_item {
  60. float: left;
  61. }
  62. </style>
  63. <script>
  64. (function(w, d, m) {
  65. function r() {
  66. var t = 100,
  67. o = 750,
  68. e = d.documentElement.clientWidth || w.innerWidth,
  69. n = m.max(m.min(e, 480), 320),
  70. h = 50;
  71. 320 >= n && (h = m.floor(n / o * t * .99)),
  72. n > 320 && 362 >= n && (h = m.floor(n / o * t * 1)),
  73. n > 362 && 375 >= n && (h = m.floor(n / o * t * 1)),
  74. n > 375 && (h = m.floor(n / o * t * .97)),
  75. d.querySelector("html").style.fontSize = h + "px"
  76. };
  77. r();
  78. w.onresize = function() {
  79. r()
  80. }
  81. })(window, document, Math);
  82. </script>
  83. </head>
  84. <body>
  85. <div class="topbar"></div>
  86. <header class="back-header back-header-bottom">
  87. <ul>
  88. <li class="padding-20 back-btn"><img class="back-header-ico" src="../../image/nav_button_back_default.png" /></li>
  89. <li class="back-header-title">评价晒单</li>
  90. <li class="more-btn"></li>
  91. </ul>
  92. </header>
  93. <section class="white-back padding-top">
  94. <div class="evaluate-item">评价<div class="my-rating"></div>
  95. </div>
  96. <div class="back-item" style="position:relative;" id="wordCount">
  97. <textarea row="5" id="content" maxlength="100" placeholder="五星好评超过20个字就有机会获得积分"></textarea>
  98. <!-- <span style="position:absolute;right:10px;bottom:5px;"><span id="count-txt">0</span>/100</span> -->
  99. <span class="wordwrap" style="bottom: -0.32rem;"><var class="word">100</var>/ 100</span>
  100. </div>
  101. <div class="h10"></div>
  102. <div style="font-size: 0.28rem;">添加图片(最多3张)</div>
  103. <div class="h5"></div>
  104. <div class="image-list">
  105. <span></span>
  106. <img id="select-image" src="../../image/addimg.png" style="width: 0.86rem;" />
  107. </div>
  108. </div>
  109. <div class="h20"></div>
  110. <div class="m-bottom">提 交</div>
  111. </section>
  112. </body>
  113. <script type="text/javascript" src="../../script/api.js"></script>
  114. <script type="text/javascript" src="../../script/jquery.min.js"></script>
  115. <script type="text/javascript" src="../../script/jquery.tap.js"></script>
  116. <script type="text/javascript" src="../../script/jquery.star-rating-svg.js"></script>
  117. <script type="text/javascript">
  118. var _imgArr = [];
  119. var _geval_scores = 0;
  120. var _geval_orderid = '';
  121. var _tImgArr = [];
  122. apiready = function() {
  123. _geval_orderid = api.pageParam.keyid;
  124. setFixStatusBar();
  125. };
  126. $(function() {
  127. var wordCount = $("#wordCount"), textArea = wordCount.find("textarea"), word = wordCount.find(".word");
  128. statInputNum(textArea, word);
  129. })
  130. $(".m-bottom").on("tap", function() {
  131. if (_geval_scores == 0) {
  132. api.toast({ msg: '请完成星级评价!' });
  133. return false;
  134. }
  135. if ($("#content").val() == "") {
  136. api.toast({ msg: '请填写反馈内容!' });
  137. return false;
  138. }
  139. _imgArr.splice(0, _imgArr.length);
  140. $(".image-list .img_item").each(function() {
  141. var _src = $(this).data("img");
  142. _imgArr.push(_src);
  143. });
  144. toast_loding_show();
  145. $.ajax({
  146. url: siteurl + 'v2/order/evaluate',
  147. data: {
  148. order_id: _geval_orderid,
  149. score: _geval_scores,
  150. content: $("#content").val(),
  151. img_list: _imgArr.toString()
  152. },
  153. headers: { "X-TOKEN": $api.getStorage("accesstoken") },
  154. dataType: 'json',
  155. type: 'post',
  156. success: function(datas) {
  157. toast_loding_hide();
  158. if (datas.result) {
  159. // setPoint();
  160. api.alert({
  161. title: '提交成功',
  162. msg: '感谢您的评价!',
  163. }, function(ret, err) {
  164. api.closeWin();
  165. });
  166. } else {
  167. errcode(datas, datas.code);
  168. }
  169. }
  170. });
  171. return false;
  172. })
  173. $(".my-rating").starRating({
  174. starSize: 23,
  175. activeColor: '#d9251c',
  176. starShape: 'rounded',
  177. hoverColor: '#d9251c',
  178. initialRating: 0,
  179. useFullStars: true,
  180. disableAfterRate: false,
  181. callback: function(currentRating, $el) {
  182. _geval_scores = currentRating;
  183. }
  184. });
  185. $(".image-list").on("tap", ".close_btn", function() {
  186. // console.log(this)
  187. _tImgArr.splice($(this).data('index')*1, 1);
  188. create_html(_tImgArr);
  189. console.log(_tImgArr);
  190. });
  191. $("#select-image").on("tap", function() {
  192. if (_tImgArr.length < 3) {
  193. var has = hasPermission('storage');
  194. if(!has || !has[0] || !has[0].granted){
  195. api.confirm({
  196. title: '提醒',
  197. msg: "没有获得 存储 权限\n是否前往设置?",
  198. buttons: ['去设置', '取消']
  199. }, function (ret, err) {
  200. var index = ret.buttonIndex;
  201. if (index == 1) {
  202. reqPermission('storage');
  203. } else {
  204. api.toast({ msg: '获取存储权限失败...' });
  205. }
  206. });
  207. // $(".border-none").removeClass("mask-hidden");
  208. return false;
  209. }
  210. api.getPicture({
  211. sourceType: 'album',
  212. encodingType: 'jpg',
  213. mediaValue: 'pic',
  214. destinationType: 'url',
  215. allowEdit: false,
  216. quality: 100,
  217. targetWidth: 600,
  218. targetHeight: 600,
  219. saveToPhotoAlbum: false
  220. }, function(ret, err) {
  221. if (ret) {
  222. upimg(ret.data);
  223. // _tImgArr.push(ret.data);
  224. }
  225. });
  226. } else {
  227. api.toast({ msg: '上传不能超过3张图片' });
  228. }
  229. })
  230. function upimg(files) {
  231. if (files) {
  232. api.ajax({
  233. url: siteurl + 'v2/upload/tmp',//'?do=upfile',
  234. method: 'post',
  235. data: {
  236. files: {
  237. file: files
  238. }
  239. },
  240. headers: { "X-TOKEN": $api.getStorage("accesstoken") }
  241. }, function(ret, err) {
  242. if (ret) {
  243. _tImgArr.push(ret.data);
  244. create_html(_tImgArr);
  245. }
  246. });
  247. }
  248. }
  249. function create_html(list){
  250. var html = '';
  251. for(var i in list){
  252. html += '<div class="img_item" data-img="'+list[i].file_name+'"><img id="select-image" class="select-image" src="' + list[i].url + '" style="width: 1.6rem;margin-right: 0.2rem;"/><span class="close_btn iconfont icon-guanbi" data-index="'+i+'"></span></div>'
  253. }
  254. $(".image-list span").html(html);
  255. }
  256. $("#content").keyup(function() {
  257. $("#count-txt").text($(this).val().length);
  258. })
  259. </script>
  260. </html>