warehouse.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. <template>
  2. <view>
  3. <view class="head">
  4. <view class="header-wrap">
  5. <view class="index-header">
  6. <uni-icons class="fanhui" custom-prefix="iconfont" type="icon-fanhui"
  7. @click="leftClick"></uni-icons>
  8. <view class="input-wrap">
  9. <text class="iconfont">选择仓库</text>
  10. </view>
  11. <view class="map-wrap"></view>
  12. </view>
  13. </view>
  14. <view class="blank"></view>
  15. </view>
  16. <view class="uni-padding-wrap uni-common-mt">
  17. <view class="button-sp-area">
  18. <br><br><br><br>
  19. <button type="primary" @click="oneStock()" class="button btn">一期库[西]</button>
  20. <br><br><br><br>
  21. <button type="success" @click="twoStock()" class="button btn">二期库[东]</button>
  22. <br><br>
  23. </view>
  24. </view>
  25. </view>
  26. </template>
  27. <script>
  28. import { storage } from '../../store/storage.js';
  29. export default {
  30. data() {
  31. return {
  32. optType: "",
  33. title: 'button',
  34. loading: false,
  35. timer: null, // 定时器
  36. }
  37. },
  38. onLoad(options) {
  39. this.timer = null; // 修正变量名(原_this改为this)
  40. this.optType = options.optType || "";
  41. },
  42. onShow() {},
  43. onUnload() {
  44. this.clearTimer();
  45. this.loading = false;
  46. },
  47. methods: {
  48. openTypeError(error) {
  49. console.error('open-type error:', error);
  50. },
  51. clearTimer() {
  52. if (this.timer != null) {
  53. clearTimeout(this.timer);
  54. this.timer = null; // 清空定时器变量
  55. }
  56. },
  57. leftClick() {
  58. setTimeout(() => {
  59. uni.navigateBack();
  60. }, 30);
  61. },
  62. async oneStock() {
  63. storage.removeItem('reqWarehouseId');
  64. let $url = "";
  65. // 4. 用 this 代替全局 _this,更安全
  66. switch (this.optType) {
  67. case "group":
  68. $url = "/pages/sample/group";
  69. break;
  70. case "out":
  71. $url = "/pages/sample/sorting_out";
  72. break;
  73. case "port":
  74. $url = "/pages/sample/port";
  75. break;
  76. case "stocktaking":
  77. $url = "/pages/sample/stocktaking";
  78. break;
  79. }
  80. const isSuccess = await storage.setItem('reqWarehouseId', "JINING-LIPAI");
  81. if (isSuccess) {
  82. setTimeout(() => {
  83. uni.vibrateShort();
  84. uni.navigateTo({ url: $url });
  85. }, 500);
  86. }
  87. },
  88. async twoStock() {
  89. storage.removeItem('reqWarehouseId');
  90. let $url = "";
  91. switch (this.optType) {
  92. case "group":
  93. $url = "/pages/sample/group";
  94. break;
  95. case "out":
  96. $url = "/pages/sample/sorting_out";
  97. break;
  98. case "port":
  99. $url = "/pages/sample/port";
  100. break;
  101. case "stocktaking":
  102. $url = "/pages/sample/stocktaking";
  103. break;
  104. }
  105. const isSuccess = await storage.setItem('reqWarehouseId', "SIMANC-B5-West");
  106. if (isSuccess) {
  107. setTimeout(() => {
  108. uni.vibrateShort();
  109. uni.navigateTo({ url: $url });
  110. }, 500);
  111. }
  112. },
  113. isEmpty(obj) {
  114. return typeof obj === 'undefined' || obj == null || obj === "" || obj === "000000000000000000000000" || obj.length === 0;
  115. }
  116. }
  117. }
  118. </script>
  119. <style>
  120. button {
  121. margin-top: 30rpx;
  122. margin-bottom: 30rpx;
  123. }
  124. .button-sp-area {
  125. margin: 0 auto;
  126. width: 60%;
  127. }
  128. .mini-btn {
  129. margin-right: 10rpx;
  130. }
  131. .button {
  132. background-color: #4CAF50;
  133. color: white;
  134. text-align: center;
  135. border-radius: 6px;
  136. box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
  137. transition: all 0.3s ease;
  138. }
  139. .button:hover {
  140. transform: scale(1.1);
  141. }
  142. </style>
  143. <style lang="scss">
  144. $color-base: #0039a6;
  145. $words-color-base: #333333;
  146. $words-color-light: #999999;
  147. .header-wrap {
  148. width: 100%;
  149. position: fixed;
  150. top: 0;
  151. z-index: 999;
  152. .index-header {
  153. height: 88upx;
  154. line-height: 88upx;
  155. padding: 0 30upx;
  156. padding-top: 40upx;
  157. background-color: $color-base;
  158. font-Size: 28upx;
  159. color: #fff;
  160. display: flex;
  161. align-items: center;
  162. justify-content: space-between;
  163. .fanhui {
  164. color: #fff !important;
  165. font-size: 28px;
  166. padding-top: 5px;
  167. font-weight: 700;
  168. }
  169. .lanya {
  170. color: #fff !important;
  171. font-size: 28px;
  172. padding-top: 5px;
  173. }
  174. .map-wrap {
  175. padding-top: 5px;
  176. }
  177. }
  178. }
  179. .blank {
  180. height: 126upx;
  181. }
  182. .btn {
  183. border-radius: 60%;
  184. width: 125px;
  185. height: 125px;
  186. margin: auto;
  187. text-align: center;
  188. line-height: 125px;
  189. border-color: #0039a6;
  190. font-size: 20px;
  191. }
  192. </style>